Skip to content

Conversation

reactormonk
Copy link
Contributor

Explicit implementation of ==, since the implicit one errors out.

@reactormonk reactormonk merged commit b7079ec into nim-lang:devel Jan 31, 2014
Clyybber pushed a commit to Clyybber/Nim that referenced this pull request Sep 16, 2023
## Summary

Move detection of inaccessible locals from `vmgen` into a pre-pass over
standalone expressions/statements passed to compile-time execution. This
makes sure that all locals reaching `transf` and the MIR phase are
valid, which is a requirement for moving away from using `PSym` for
locals in the code generators.

## Details

- implement the check for whether unavailable locals are accessed in the
  new `semcomptime` module
- integrate the check into `evalConstExprAux`, where it short-circuits
  code generation in case of an error
- add a dedicated diagnostic for using unavailable locals in compile-
  time contexts (`adSemUnavailableLocation`/`rsemUnavailableLocation`)
- adjust the tests using the old error message
- remove from `vmgen` the checks regarding whether access of a local is
  valid

Implementation-wise, the check works by traversing the AST, registering
all symbols in a set as they're declared, and then, on use, checking
whether non-global symbol are present in the set. If not, the node
with the problematic symbol is propagated back to the callsite, where it
is wrapped in an error node.

While it would be possible to integrate the check into `sempass2`, the
future of the latter isn't entirely clear and the pass is at present
also not run for standalone compile-time expressions/statements.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant