Skip to content

Assignment from keyword field of type &T to variable of type not-&T is mistakenly well-typed #2844

Description

@sungshik

Describe the bug

The following test currently succeeds:

test bool ADTWithTypeParameterAndKW3() = checkModuleOK("
module ADTWithTypeParameterAndKW3
data D[&T] = d1(&T n, &T kw = n);
void f() { D[int] x = d1(10); str m = x.kw; }
");

However, it should fail, because:

  • &T is bound to int;
  • the type of x.kw is int;
  • the type of m is str.

A preliminary investigation suggests that the req that compares the types of m and x.kw is triggered too early by the solver (when it hasn't established yet that &T is bound to int), possibly because of a missing dependency. Need to look into this in more detail.

To Reproduce

Run the test.

Expected behavior

The test should fail.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions