Wrong error for "variable not declared"
Closed this issue · 3 comments
While writing some syntax test files, I noticed that lslint
(v1.0.8) reports a "variable not declared" error for declared variables who've been assigned invalid syntax.
Minimal example below where an error is reported by lslint
(v1.0.8) for test
in line 12:
default
{
touch_end(integer num_detected)
{
return;
list test = [
event
// ^^^^^ invalid.unimplemented.lsl
];
llRegionSayTo(llDetectedKey(0), PUBLIC_CHANNEL, (string)llGetListLength(test));
}
}
I get this output with the above script:
ERROR:: ( 8, 13): syntax error, unexpected EVENT, expecting ']'
ERROR:: ( 12, 81): `test' is undeclared.
This is the expected output. The syntax error prevents the parser from fully recognizing the declaration as such, therefore the declaration of the variable does not get completed, therefore it does not get declared.
I went into more details about the cause, as it applies to a similar problem, here: #46 (comment)
In your case, it manages to recover at the semicolon after the declaration, and since there are no other syntax errors impeding it, it is then able to gather a complete script, unlike in the linked example's case.
Error recovery is a very difficult topic, see here (that's why the sim's LSL compiler doesn't do any). lslint uses Bison (a successor of YACC), which operates in "Panic mode"; see here. Don't expect to see any changes in that area.
Don't expect to see any changes in that area.
After taking a more detailed look, I take that back. #61 introduces improvements, but for some reason it doesn't address this particular test case. I'm looking into it.
OK, cause found and fixed.