Skip to content

Typechecker does not correctly compute type of implicitly defined set #2333

@toinehartman

Description

@toinehartman

Describe the bug

Typechecker does not correctly compute type of implicitly defined set.
Also checked feature branch compiled-parser-generator (latest commit, 22f79cb at the time of writing) which only throws an erro in f2).

To Reproduce

Run the following program:

module CheckerBug

import IO;
import util::FileSystem;
import util::Reflective;
import lang::rascalcore::check::Checker;

str prog = "module Example

set[loc] f1() {
    r = {}; // inferred type
    for (int i \<- {6}) { // explicit type
        r += i;
    }

    return r; // Return type `set[loc]` expected, found `set[int]`
}

set[loc] f2() {
    set[int] r = {}; // explicit type
    for (i \<- {6}) { // inferred type
        r += i;
    }

    return r; // Return type `set[loc]` expected, found `set[int]`
}

set[loc] f3() {
    r = {}; // inferred type
    for (i \<- {6}) { // inferred type
        r += i;
    }

    return r; // no error
}";

void main(loc projDir = |memory://test-project|) {
    pcfg = makePathConfig([projDir], []);
    ccfg = rascalCompilerConfig(pcfg);

    srcFile = pcfg.srcs[0] + "Example.rsc";

    remove(pcfg.bin); // clean
    writeFile(srcFile, prog); // write program

    msgs = check([srcFile], ccfg);
    iprintln(msgs); // expected 3 errors, but got 2
}

Expected behavior
An error to be thrown in f3 as well.

Screenshots

Image

Desktop (please complete the following information):

  • Context: everywhere
  • Rascal Version: 0.41.0-RC55-SNAPSHOT

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions