rascal icon indicating copy to clipboard operation
rascal copied to clipboard

`Maybe::nothing` causes wrong type if used in adt keyword parameters

Open DavyLandman opened this issue 1 year ago • 0 comments

Describe the bug

The nothing() adt constructor with a generic type fails to correclty type-check, in case of a keyword argument to an ADT. With the following error: Default expression of type Maybe[str] expected, found Maybe[&A]

To Reproduce

import util::Maybe;

data X = contain(
    Maybe[bool] pos1,
    Maybe[int] y = just(2), // fine
    Maybe[str] z = nothing() // error
);

void main() {
    Maybe[str] x = nothing(); // fine
    x = nothing(); // fine

    x2 = contain(nothing()); // fine as positional argument
    x2.z = just("hi"); // fine
    x2.y = nothing(); // error
}

Expected behavior It should typecheck fine.

Desktop (please complete the following information):

  • Context: VS Code extension & maven pluging
  • Rascal Version: rascal-core 0.12.3

DavyLandman avatar Aug 30 '24 14:08 DavyLandman