-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Labels
compilerGeneral compiler tagGeneral compiler tagcompiler/msgsCompiler output and diagnostic subsystem: error and warnig reporting, information, debuggingCompiler output and diagnostic subsystem: error and warnig reporting, information, debuggingcompiler/semRelated to semantic-analysis system of the compilerRelated to semantic-analysis system of the compiler
Milestone
Description
Summary
Change the diagnostic handling to be effect-based, meaning that emitting a diagnostic is treated as an effect that has to be handled via an effect handler.
In addition, remove the wrap-trees-at-ever-layer propagation of errors through AST.
Goals
- simplify handling of errors and diagnostics in general, especially during semantic analysis
- significantly simplify semantic analysis, by no longer having to wrap all sub-trees that contain errors somewhere
- speed up semantic analysis (by not having to keep track of errors anymore)
- improve type inference for erroneous code, to allow for better code suggestions, hover information, etc. when the code has errors
Concrete Steps
Note: these are not necessarily all steps there are, just the obvious ones. They're listed in roughly the order they can be worked on, but some of them are possible to be worked on concurrently.
- msgs: use effect-based diagnostic emission/handling #1593
- rename
localReport
toemit
oremitDiag
. So that the name properly reflects the routine's purpose. - rename
globalReport
toemitFatal
, or similar. So that the name properly reflects the routine's purpose. - make the report hook return
void
instead ofTErrorHandling
. The report hook is solely meant for reporting (i.e., rendering and display) -- it should have no say in further diagnostic handling. - don't store error nodes in
tyError
.tyError
has to become a dedicated type kind, with error types then used to give a type to expressions whose type couldn't be inferred due to an error. - remove
skError
. Some symbol-returning routines currently useskError
to signal that an error occurred.qualifiedLookUp
andlookUp
are major users ofskError
; using a different strategy to signal errors will likely require a broader rework of the routines and their callsites. - treat
tyError
like a normal type in all of sem. How to treat the type depends on the exact context. The goal is to reduce the amount of cascading errors (ideally eliminating them), while still typing the code as much as possible. - don't evaluate macros/templates whose operands are erroneous. (without relying on
nkError
). - don't evaluate compile-time code that accesses erroneous symbols. Necessary in order to prevent
nkError
nodes from reaching compile-time processing (via, e.g.,getImpl
). - remove
wrapError
andadSemWrappedError
nodes. Remove all error "wrapping" from the compiler. This is doable in small increments. - remove
CheckedAst
andProductionAst
. The types were intended to make error wrapping easier, meaning that they no longer serve a purpose once error wrapping is gone. - remove the
DebugReport
andInternalReport
type. Debug and internal events/messages need to use a separate channel -- they must not be conflated with general diagnostics and reporting.
If you're interested in working on any of these tasks, please ping @zerbina.
Metadata
Metadata
Assignees
Labels
compilerGeneral compiler tagGeneral compiler tagcompiler/msgsCompiler output and diagnostic subsystem: error and warnig reporting, information, debuggingCompiler output and diagnostic subsystem: error and warnig reporting, information, debuggingcompiler/semRelated to semantic-analysis system of the compilerRelated to semantic-analysis system of the compiler