You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
procgeneric[T](x: T) =
missing # provoke the generic pre-pass to fail (via a symbol lookup error) procf(p: proc(x: int)) =discardf(generic) # <- instantiation is attempted even though the symbol is erroneous
Actual Output
Error: unhandled exception: field 'sons' is not accessible for type 'TNode' using 'kind = nkError' [FieldDefect]
Expected Output
Error: undeclared identifier: 'missing'
Possible Solution
Analyzing the expression goes through semExpr, but not semSym (which would have wrapped the symbol usage in an error), due to the symbol being a skProc.
If the symChoice call part of the nkIdent handling of semExpr results in a single symbol, the symbol can be checked (and wrapped in an error) early. For the case where a symbol-choice is returned, the error wrapping can only happen where the choice is ultimately resolved.
The text was updated successfully, but these errors were encountered:
## Summary
Fix a compiler crash when passing the name of a procedure with an error
as an argument to another routine.
## Details
Overloadable and overloaded procedure symbols forewent the `nkError`
wrapping done by `semSym`, thus not preventing instantiation or later
inspection by `sempass2`, crashing the compiler with an `IndexDefect`
on attempting to access the symbol's AST.
Non-overloaded procedure symbols can be passed to `semSym` directly,
which takes care of the wrapping. To handle overloaded symbols,
`sigmatch.paramTypesMatch` passes the picked symbol to `semExpr` first,
which subsequently calls `semSym`, also marking the symbols as used.
The problem with using `semExpr` in `paramTypesMatch` is that the
returned `nkError` currently dismisses the overload, resulting in an
unnecessary "type mismatch" compiler error (with `nimsuggest`, `check`,
etc.).
Fixes#1384.
Fixes#1442.
Example
Actual Output
Expected Output
Possible Solution
Analyzing the expression goes through
semExpr
, but notsemSym
(which would have wrapped the symbol usage in an error), due to the symbol being askProc
.If the
symChoice
call part of thenkIdent
handling ofsemExpr
results in a single symbol, the symbol can be checked (and wrapped in an error) early. For the case where a symbol-choice is returned, the error wrapping can only happen where the choice is ultimately resolved.The text was updated successfully, but these errors were encountered: