Skip to content

Shadowing of higher-order function names is incorrect #2575

@rodinaarssen

Description

@rodinaarssen

Describe the bug

While bringing rascal-lucene up to date with the latest Rascal release, I stumbled upon a situation where the name of a higher-order function was not resolved correctly. I've tried to make this report as concise as possible, but I'm afraid it's still rather large.

The module analysis::text::search::Grammars contains a function isToken (of type bool(Tree)) and a function tokens (with signature list[Tree] tokens(Tree tok, bool(Tree) isToken). Note that the name isToken appears in two scopes. When calling the latter function with yet another function as parameter (i.c.: isComment), the isToken function that was called inside the tokens function did not resolve to isComment, but to (the global) isToken instead.

To Reproduce

  1. Open the rascal-lucene project (v0.1.0) in VS Code with version 0.13.0 of the Rascal extension.
  2. Start a REPL in this project and execute the following and observe that the output of the final two function calls is the same (isComment was executed in both calls to tokens).
import IO;
import ParseTree;
import lang::pico::\syntax::Main;
import analysis::text::search::Grammars;
l = |project://rascal-lucene/src/analysis/text/search/testdata/Fac.pico|;
pt = parse(#start[Program], readFile(l));
tokens(pt, isComment)
tokens(pt, isToken)
  1. Start a new REPL and execute the same commands, swapping the final two. Again, observe that the output is equals; however, it is not the same as in the previous step ((the global) isToken was executed in both calls to tokens).

Expected behavior
The output of these function calls should not be equal.

Desktop (please complete the following information):

  • VS Code 0.13.0

Additional context

  • This behavior was introduced between Rascal 0.41.0-RC76 and 0.41.0-RC77. In this time, caches around resolution of function names were introduced.
  • I suspect that the caching around the resolution of isToken and/or isComment is too eager/faulty.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions