proc generic[T](x: T) =
missing # provoke the generic pre-pass to fail (via a symbol lookup error)
proc f(p: proc(x: int)) =
discard
f(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.
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.