usethesource / rascal

The implementation of the Rascal meta-programming language (including interpreter, type checker, parser generator, compiler and JVM based run-time system)
http://www.rascal-mpl.org
Other
404 stars 78 forks source link

type-checker IndexOutOfBounds on salix::demo::ide::IDE #1405

Closed jurgenvinju closed 4 years ago

jurgenvinju commented 4 years ago

Describe the bug

Will have to simplify this case later; registering now for future reference.

BTW, this error message was produced with the rascal-maven-plugin-0.2.14 which prints the Rascal stack trace for the checker in such a case.

[ERROR]     IndexOutOfBounds(2)
at filterOverloads(|lib://rascal-core/lang/rascalcore/check/CollectExpression.rsc|(31022,64,<719,69>,<719,133>))
    at Anonymous Function(|lib://rascal-core/lang/rascalcore/check/CollectExpression.rsc|(24976,42,<620,54>,<620,96>))
    at evalCalc(|lib://typepal/analysis/typepal/Solver.rsc|(17251,34,<497,29>,<497,63>))
    at evalOrScheduleCalc(|lib://typepal/analysis/typepal/Solver.rsc|(14669,120,<429,12>,<433,13>))
    at fireTrigger(|lib://typepal/analysis/typepal/Solver.rsc|(11790,25,<345,12>,<345,37>))
    at addFact(|lib://typepal/analysis/typepal/Solver.rsc|(13036,15,<383,8>,<383,23>))
    at _run(|lib://typepal/analysis/typepal/Solver.rsc|(57951,27,<1490,24>,<1490,51>))
    at rascalTModelComponent(|lib://rascal-core/lang/rascalcore/check/Checker.rsc|(19560,8,<421,9>,<421,17>))
    at rascalTModelForLocs(|lib://rascal-core/lang/rascalcore/check/Checker.rsc|(13527,85,<295,29>,<295,114>))
    at check(|lib://rascal-core/lang/rascalcore/check/Checker.rsc|(20781,97,<457,38>,<457,135>))
    at ***MVN Rascal Compiler***(|main://***MVN%20Rascal%20Compiler***|)

To Reproduce

jurgenvinju commented 4 years ago

in CollectionExpression, line 713, it says arity >= size(formals) - 1 and I don't understand why it is not arity == size(formals) - 1; could this be the cause of the issue?

PaulKlint commented 4 years ago

The reported error is triggered in salix::demo::ide::IDE.

Here is an initial assessment of the salix library:

37 files, 13 with a problem, 1 crashed, 0 skipped

With errors: ["salix::Patch","salix::SVG","salix::demo::basic::Readme","salix::demo::graphs::DagreDemo","salix::demo::ide::LiveQL","salix::demo::ide::Richtext","salix::demo::shop::Shop","salix::demo::treeview::TreeViewDemo","salix::lib::Debug","salix::lib::Highlight","salix::lib::UML","salix::lib::XTerm","salix::tests::EventDiscarding"]

Crashed: ("salix::demo::ide::IDE":IndexOutOfBounds(2))

PaulKlint commented 4 years ago

The test arity >= size(formals) - 1 describes the case of varargs:

The number of variadic actual parameters can be >= 0.

Therefore arity >= size(formals) - 1 covers all cases that there are 0, 1, ..., variadic actual parameters.

PaulKlint commented 4 years ago

The problem was caused by overloaded functions where each overload has different arity and a varargs argument. I have added a check for this.

Type checking the whole of salix is now enabled.

joukestoel commented 4 years ago

Cool! I'll see if I can remove the type errors from the rest of Salix in the coming period.