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
As a side-note, neither b nor x are closures here, as both don't close over any local variable. The reason for c(x) needing to be nested in another inner procedure (for the crash to happen) is that sempass2 would not be run for the call otherwise, since the error in b properly propagates, disabling sempass2 for a.
The following:
procc(x: proc()) =discardprocb() =
missing
c(b)
would also crash the compiler, but only when the maximum allowed number of errors is larger than 1 (which is the case for, e.g., check and nimsuggest).
## 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.
Specification
When a closure has an error, the compiler crash when you try to pass it to a function while inside another closure.
Example
Actual Output
Expected Output
The text was updated successfully, but these errors were encountered: