diff --git a/src/typing/typer.ml b/src/typing/typer.ml index a2b74023129..d54c9a33677 100644 --- a/src/typing/typer.ml +++ b/src/typing/typer.ml @@ -401,7 +401,7 @@ let rec type_ident_raise ctx i p mode with_type = | TMono r when not (is_nullable t) -> (* If our expected type is a monomorph, bind it to Null. The is_nullable check is here because the expected type could already be Null, in which case we don't want to double-wrap (issue #11286). *) - Monomorph.do_bind r (tnull()) + Monomorph.bind r (tnull()) | _ -> (* Otherwise there's no need to create a monomorph, we can just type the null literal the way we expect it. *) diff --git a/tests/misc/projects/Issue11753/Main.hx b/tests/misc/projects/Issue11753/Main.hx new file mode 100644 index 00000000000..18e0e373dd6 --- /dev/null +++ b/tests/misc/projects/Issue11753/Main.hx @@ -0,0 +1,31 @@ +class Main { + static var doThings : Foo -> Void; + + static function main() { + var foo = new Foo(); + doThings = (foo -> doThingsImpl(foo)); + doThings(foo); + } + + static function doThingsImpl(foo) { + foo.doWithBar(); + $type(foo); + $type(foo.doWithBar); + + if (foo != null) trace(foo); + $type(foo); + $type(foo.doWithBar); + } +} + +class Foo { + public function new() {} + public function doWithBar(?bar:Bar) { + trace(bar); + } +} + +@:keep +class Bar { + public function new() {} +} diff --git a/tests/misc/projects/Issue11753/compile-fail.hxml b/tests/misc/projects/Issue11753/compile-fail.hxml new file mode 100644 index 00000000000..e3c103b20f6 --- /dev/null +++ b/tests/misc/projects/Issue11753/compile-fail.hxml @@ -0,0 +1,4 @@ +-main Main +--hl bin/main.hl +-D message.reporting=pretty +-D message.no-color diff --git a/tests/misc/projects/Issue11753/compile-fail.hxml.stderr b/tests/misc/projects/Issue11753/compile-fail.hxml.stderr new file mode 100644 index 00000000000..10671cc1f80 --- /dev/null +++ b/tests/misc/projects/Issue11753/compile-fail.hxml.stderr @@ -0,0 +1,32 @@ +[WARNING] Main.hx:12: characters 9-12 + + 12 | $type(foo); + | ^^^ + | Unknown<0> : { doWithBar : () -> Unknown<1> } + +[WARNING] Main.hx:13: characters 9-22 + + 13 | $type(foo.doWithBar); + | ^^^^^^^^^^^^^ + | () -> Unknown<0> + +[WARNING] Main.hx:16: characters 9-12 + + 16 | $type(foo); + | ^^^ + | Null<{ doWithBar : () -> Unknown<0> }> + +[WARNING] Main.hx:17: characters 9-22 + + 17 | $type(foo.doWithBar); + | ^^^^^^^^^^^^^ + | () -> Unknown<0> + +[ERROR] Main.hx:6: characters 35-38 + + 6 | doThings = (foo -> doThingsImpl(foo)); + | ^^^ + | error: (?bar : Null) -> Void should be () -> Unknown<0> + | have: { doWithBar: (?...) -> ... } + | want: { doWithBar: () -> ... } +