Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
kLabz committed Aug 30, 2024
1 parent 9fc0dbb commit 42c2aad
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
31 changes: 31 additions & 0 deletions tests/misc/projects/Issue11753/Main.hx
Original file line number Diff line number Diff line change
@@ -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() {}
}
3 changes: 3 additions & 0 deletions tests/misc/projects/Issue11753/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-main Main
--hl bin/main.hl
-D message.no-color
30 changes: 30 additions & 0 deletions tests/misc/projects/Issue11753/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[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<Unknown<0>>

[WARNING] Main.hx:17: characters 9-22

17 | $type(foo.doWithBar);
| ^^^^^^^^^^^^^
| Unknown<0>

[ERROR] Main.hx:11: characters 3-16

11 | foo.doWithBar();
| ^^^^^^^^^^^^^
| Don't know how to cast (Bar):void to ():dyn

0 comments on commit 42c2aad

Please sign in to comment.