Replies: 1 comment 1 reply
|
Hey @aabounegm, Let's say you have some sort of AST structure like this: You can then simply traverse the tree, and use a map on each level (filled with the names of variables on that level) and descent into the tree carrying the maps of previous levels along. If a variable is encountered that already is in one of the maps, generate an error. Theoretically, if your |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The language I'm working on supports many ways of introducing symbols to the scope (such as declaring named functions, function parameters,
letbindings,try-catch, patterns, ...). The default scope provider works fine for most of them, but I needed to write a custom scope provider since not all of them were detected by the default implementation.Now, I would like to display a warning whenever a variable (or parameter, ...) name shadows an existing symbol. What is the simplest way to detect whenever any symbol declaration shadows a previous declaration?
All reactions