-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Labels
Description
It seems that the behaviour of double declarations differs over the course of severel releases.
Example tests:
module Bug
extend analysis::typepal::Collector; // extend instead of import to work around https://github.com/usethesource/rascal/pull/2592
import analysis::typepal::Solver;
import IO;
import String;
start syntax Program = "";
start[Program] pt = [start[Program]] "";
// No overloading of names allowed!
TypePalConfig conf = tconfig(mayOverload = bool(set[loc] _, map[loc, Define] _) { return false; });
data IdRole = function() | variable();
TModel model(Tree pt, Collector c) {
tm = newSolver(pt, c.run()).run();
print("Messages: ");
iprintln(tm.messages);
return tm;
}
int countErrors(TModel tm) = size({e | /e:error(_, _) := tm.messages});
test bool predefineDefine() {
c = newCollector("Checker", pt, conf);
c.predefine("foo", function(), |unknown:///|, noDefInfo());
c.define("foo", variable(), |unknown:///|, noDefInfo());
tm = model(pt, c);
return countErrors(tm) == 0;
}
test bool defineDefine() {
c = newCollector("Checker", pt, conf);
c.define("foo", function(), |unknown:///|, noDefInfo());
c.define("foo", variable(), |unknown:///|, noDefInfo());
tm = model(pt, c);
return countErrors(tm) == 0;
}
test bool predefinePredefine() {
c = newCollector("Checker", pt, conf);
c.define("foo", function(), |unknown:///|, noDefInfo());
c.define("foo", variable(), |unknown:///|, noDefInfo());
tm = model(pt, c);
return countErrors(tm) == 0;
}All tested with Rascal 0.41.2.
| Release | Predefine+define | Predefine+predefine | Define+define |
|---|---|---|---|
| 0.15.0 | ✅ (0) | ✅ (0) | ✅ (0) |
| 0.15.1 | ✅ (0) | ✅ (0) | ✅ (0) |
| 0.15.2 | ❌ (2) | ✅ (0) | ✅ (0) |
| 0.15.3 | ❌ (2) | ✅ (0) | ✅ (0) |
| 0.15.4 | ❌ (2) | ✅ (0) | ✅ (0) |
| 0.15.5 | ❌ (2) | ✅ (0) | ✅ (0) |
| 0.16.0 | ✅ (0) | ✅ (0) | ✅ (0) |
| 0.16.1 | ✅ (0) | ✅ (0) | ✅ (0) |
To be fair, I am surprised that the predfine/define define/define combinations never result in double declarations. Nonetheless, the fluctuating semantics here are a concern.
jurgenvinju and urbanfly