Skip to content

Differing behaviour of predefine accross release versions #35

@toinehartman

Description

@toinehartman

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions