Open Meowcolm024 opened 10 months ago
Minimized:
abstract class Foo[T]: Foo[Int]
(f: Foo['a]) => f : Str
Minimized further (but the trace looks different):
abstract class Foo: Foo
(f: Foo) => f : Str
Another one:
type Foo = Foo & Int
(f: Foo) => f : Str
We have to be more careful when we expand types during normalization...
Note that this only happens on the "new parser/typer frontend" (https://github.com/hkust-taco/mlscript/pull/187). In the legacy frontend, we were careful to check for cycles in definitions and yielded "Error in class definitions: illegal cycle involving type Foo" for the latter example. We have to adapt these sorts of checks to the new frontend.
Of course, we can also get unsoundness from such ill-formed types:
type A = A
//│ type A = A
(1 : A)()
//│ nothing
//│ res
//│ Runtime error:
//│ TypeError: 1 is not a function
The following code causes an infinite loop in type checking
Bar
, we haveBar => (#Bar<Object,Foo> & Bar)
Bar
, we haveBar => #Bar<Object,Foo>