- Rascal does not allow uninitialized variables at all, but it should complain about "uninitialized" in that case, not "undeclared"
- It is not finding your variable. Could you try adding "example::" before dereferencing?
Variable unknown when not initialized in the declaration
-
13-04-2022 - |
Question
I ran into this today, and I was wondering if something is going wrong here.
module example
public rel[str file, AstNode namespace] relFileNamespace;
public void InitGlobals()
{
relFileNamespace = {};
}
Then in the console:
rascal>import example;
ok
rascal>InitGlobals();
ok
rascal>relFileNamespace
|stdin:///|(0,13,<1,0>,<1,13>): Undeclared variable, function or constructor: relFileNamespace
If I declare it like this it does work.
public rel[str file, AstNode namespace] relFileNamespace = {};
So the question is, why does it have to be initialized in the declaration?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow