HaxeFoundation / haxe

Haxe - The Cross-Platform Toolkit
https://haxe.org
6.03k stars 648 forks source link

Compiler failure tUnification unknown position #11684

Closed yuxiaomao closed 4 weeks ago

yuxiaomao commented 4 weeks ago

With the following code (https://try.haxe.org/#5Ff39D07), which is a real use case when reading json file

public static function test(input) {
    return (input is Array) ? input[0] : input;
}

Compiler failure for 4.3.0, 4.3.4 and nightly.

[ERROR] (unknown position)

   | Error: Compiler failure
   | Please submit an issue at https://github.com/HaxeFoundation/haxe/issues/new
   | Attach the following information:
   | Haxe: 5.0.0-alpha.1+2d9ed26; OS type: unix;
   | File "src/core/tUnification.ml", line 1274, characters 22-29
   | Called from file "src/typing/typer.ml", line 256, characters 15-79

Does not produce error if input or return type are explicitly typed to Dynamic.