diff --git a/src/typing/typeload.ml b/src/typing/typeload.ml index c59330fc8f5..f1ba7dcb4c2 100644 --- a/src/typing/typeload.ml +++ b/src/typing/typeload.ml @@ -416,34 +416,50 @@ and load_instance' ctx ptp get_params mode = with Not_found -> let mt = load_type_def ctx (if ptp.pos_path == null_pos then ptp.pos_full else ptp.pos_path) t in let info = ctx.g.get_build_info ctx mt ptp.pos_full in - if info.build_path = ([],"Dynamic") then match t.tparams with - | [] -> t_dynamic - | [TPType t] -> TDynamic (Some (load_complex_type ctx true LoadNormal t)) - | _ -> raise_typing_error "Too many parameters for Dynamic" ptp.pos_full - else if info.build_params = [] then begin match t.tparams with - | [] -> - info.build_apply [] - | tp :: _ -> - let pt = match tp with - | TPType(_,p) | TPExpr(_,p) -> p - in - display_error ctx.com ("Too many type parameters for " ^ s_type_path info.build_path) pt; - info.build_apply [] - end else begin - (* TODO: this is currently duplicated, but it seems suspcious anyway... *) - let is_rest = info.build_kind = BuildGenericBuild && (match info.build_params with [{ttp_name="Rest"}] -> true | _ -> false) in - let tl = if t.tparams = [] && not is_rest then begin match get_params with - | ParamNormal -> + begin match info.build_path with + | ([],"Dynamic") -> + begin match t.tparams with + | [] -> t_dynamic + | [TPType t] -> TDynamic (Some (load_complex_type ctx true LoadNormal t)) + | _ -> raise_typing_error "Too many parameters for Dynamic" ptp.pos_full + end + | ([],"Void") -> + begin match mode with + | LoadReturn | LoadAny -> + ctx.t.tvoid + | _ -> + (* VOIDTODO: I don't think we actually want this, but let's try to get green CI *) + if has_class_flag ctx.c.curclass CExtern then + ctx.t.tvoid + else + raise_typing_error "Cannot use Void here" ptp.pos_full + end + | _ -> + if info.build_params = [] then begin match t.tparams with + | [] -> + info.build_apply [] + | tp :: _ -> + let pt = match tp with + | TPType(_,p) | TPExpr(_,p) -> p + in + display_error ctx.com ("Too many type parameters for " ^ s_type_path info.build_path) pt; + info.build_apply [] + end else begin + (* TODO: this is currently duplicated, but it seems suspcious anyway... *) + let is_rest = info.build_kind = BuildGenericBuild && (match info.build_params with [{ttp_name="Rest"}] -> true | _ -> false) in + let tl = if t.tparams = [] && not is_rest then begin match get_params with + | ParamNormal -> + load_params ctx info t.tparams ptp.pos_full + | ParamSpawnMonos -> + Monomorph.spawn_constrained_monos (fun t -> t) info.build_params + | ParamCustom f -> + f info None + end else load_params ctx info t.tparams ptp.pos_full - | ParamSpawnMonos -> - Monomorph.spawn_constrained_monos (fun t -> t) info.build_params - | ParamCustom f -> - f info None - end else - load_params ctx info t.tparams ptp.pos_full - in - let t = info.build_apply tl in - maybe_build_instance ctx t get_params ptp.pos_full + in + let t = info.build_apply tl in + maybe_build_instance ctx t get_params ptp.pos_full + end end and load_instance ctx ?(allow_display=false) ptp get_params mode = @@ -629,7 +645,7 @@ and load_complex_type' ctx allow_display mode (t,p) = | CTFunction (args,r) -> match args with | [CTPath { path = {tpackage = []; tparams = []; tname = "Void" }},_] -> - TFun ([],load_complex_type ctx allow_display LoadReturn r) + TFun ([],load_complex_type ctx allow_display LoadReturn r) | _ -> TFun (List.map (fun t -> let t, opt = (match fst t with CTOptional t | CTParent((CTOptional t,_)) -> t, true | _ -> t,false) in diff --git a/std/haxe/NoValue.hx b/std/haxe/NoValue.hx new file mode 100644 index 00000000000..ba34e3ea89d --- /dev/null +++ b/std/haxe/NoValue.hx @@ -0,0 +1,3 @@ +package haxe; + +enum NoValue {} diff --git a/std/haxe/display/Diagnostic.hx b/std/haxe/display/Diagnostic.hx index 461a8c1f508..7490613035f 100644 --- a/std/haxe/display/Diagnostic.hx +++ b/std/haxe/display/Diagnostic.hx @@ -1,9 +1,9 @@ // from vshaxe package haxe.display; +import haxe.display.JsonModuleTypes; import haxe.display.Position.Location; import haxe.display.Position.Range; -import haxe.display.JsonModuleTypes; enum abstract UnresolvedIdentifierSuggestion(Int) { var UISImport; @@ -53,13 +53,13 @@ typedef ReplacableCode = { } enum abstract DiagnosticKind(Int) from Int to Int { - final DKUnusedImport:DiagnosticKind; + final DKUnusedImport:DiagnosticKind; final DKUnresolvedIdentifier:DiagnosticKind>; final DKCompilerError:DiagnosticKind; final ReplacableCode:DiagnosticKind; final DKParserError:DiagnosticKind; final DeprecationWarning:DiagnosticKind; - final InactiveBlock:DiagnosticKind; + final InactiveBlock:DiagnosticKind; final MissingFields:DiagnosticKind; } diff --git a/tests/misc/projects/Issue10959/TestClass.hx b/tests/misc/projects/Issue10959/TestClass.hx index 0713ff811a2..ce71629d269 100644 --- a/tests/misc/projects/Issue10959/TestClass.hx +++ b/tests/misc/projects/Issue10959/TestClass.hx @@ -1,5 +1,5 @@ package; @:keep -class TestClass { +class TestClass { } diff --git a/tests/misc/projects/Issue10959/build.hxml.stdout b/tests/misc/projects/Issue10959/build.hxml.stdout index 8133ffd83dc..29d1acccf10 100644 --- a/tests/misc/projects/Issue10959/build.hxml.stdout +++ b/tests/misc/projects/Issue10959/build.hxml.stdout @@ -1,10 +1,10 @@ On Generate -- Too Few Params -- Before: TestClass -After: TestClass +After: TestClass Before: TestClass -After: TestClass +After: TestClass -- Too Many Params -- Before: TestClass @@ -15,7 +15,7 @@ Before: TestClass After: TestClass Before: TestClass -After: TestClass +After: TestClass -- Shouldn't Have Params -- Before: Void @@ -23,7 +23,7 @@ After: Void -- Recursive Test -- Before: TestClass> -After: TestClass, TestClass, Void> +After: TestClass, TestClass, haxe.NoValue> -- Fill With Specific Type -- Before: TestClass diff --git a/tests/misc/projects/Issue6201/compile2-fail.hxml.stderr b/tests/misc/projects/Issue6201/compile2-fail.hxml.stderr index 6c7a8df4361..f4ce5e98c16 100644 --- a/tests/misc/projects/Issue6201/compile2-fail.hxml.stderr +++ b/tests/misc/projects/Issue6201/compile2-fail.hxml.stderr @@ -1 +1 @@ -Main2.hx:3: characters 7-8 : Variables of type Void are not allowed \ No newline at end of file +Main2.hx:3: characters 9-13 : Cannot use Void here \ No newline at end of file diff --git a/tests/misc/projects/Issue6810/.gitignore b/tests/misc/projects/Issue6810/.gitignore deleted file mode 100644 index b6e9ee09221..00000000000 --- a/tests/misc/projects/Issue6810/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -logfile-02-fail.hxml.stderr -logfile-03-fail.hxml.stderr -logfile-04-fail.hxml.stderr diff --git a/tests/misc/projects/Issue6810/Fail.hx b/tests/misc/projects/Issue6810/Fail.hx deleted file mode 100644 index 19ff1dd7593..00000000000 --- a/tests/misc/projects/Issue6810/Fail.hx +++ /dev/null @@ -1,14 +0,0 @@ -import haxe.Constraints.NotVoid; - -typedef FakeVoid = Void; - -class Fail { - public static function main() { - test(void); - test(fakeVoid); - } - - static function void():Void {} - static function fakeVoid():FakeVoid {} - static function test(f:()->T):T return f(); -} diff --git a/tests/misc/projects/Issue6810/Main.hx b/tests/misc/projects/Issue6810/Main.hx deleted file mode 100644 index 2d70e15b0c3..00000000000 --- a/tests/misc/projects/Issue6810/Main.hx +++ /dev/null @@ -1,11 +0,0 @@ -import haxe.Constraints.NotVoid; - -class Main { - public static function main() { - test(function() return 42); - test(function() return "test"); - } - - static function test(f:()->T):T return f(); -} - diff --git a/tests/misc/projects/Issue6810/compile-fail.hxml b/tests/misc/projects/Issue6810/compile-fail.hxml deleted file mode 100644 index 7acf375871c..00000000000 --- a/tests/misc/projects/Issue6810/compile-fail.hxml +++ /dev/null @@ -1 +0,0 @@ -Fail diff --git a/tests/misc/projects/Issue6810/compile-fail.hxml.stderr b/tests/misc/projects/Issue6810/compile-fail.hxml.stderr deleted file mode 100644 index 9b8975b022b..00000000000 --- a/tests/misc/projects/Issue6810/compile-fail.hxml.stderr +++ /dev/null @@ -1,6 +0,0 @@ -Fail.hx:7: characters 8-12 : error: Void should be haxe.NotVoid -Fail.hx:7: characters 8-12 : ... have: (...) -> Void -Fail.hx:7: characters 8-12 : ... want: (...) -> haxe.NotVoid -Fail.hx:8: characters 8-16 : error: FakeVoid should be haxe.NotVoid -Fail.hx:8: characters 8-16 : ... have: (...) -> FakeVoid -Fail.hx:8: characters 8-16 : ... want: (...) -> haxe.NotVoid diff --git a/tests/misc/projects/Issue6810/compile.hxml b/tests/misc/projects/Issue6810/compile.hxml deleted file mode 100644 index 42409e72918..00000000000 --- a/tests/misc/projects/Issue6810/compile.hxml +++ /dev/null @@ -1 +0,0 @@ --main Main diff --git a/tests/misc/projects/Issue6810/indent-fail.hxml b/tests/misc/projects/Issue6810/indent-fail.hxml deleted file mode 100644 index 03324ef398b..00000000000 --- a/tests/misc/projects/Issue6810/indent-fail.hxml +++ /dev/null @@ -1,2 +0,0 @@ -compile-fail.hxml --D message.reporting=indent diff --git a/tests/misc/projects/Issue6810/indent-fail.hxml.stderr b/tests/misc/projects/Issue6810/indent-fail.hxml.stderr deleted file mode 100644 index 933eedd4c67..00000000000 --- a/tests/misc/projects/Issue6810/indent-fail.hxml.stderr +++ /dev/null @@ -1,6 +0,0 @@ -Fail.hx:7: characters 8-12 : error: Void should be haxe.NotVoid - Fail.hx:7: characters 8-12 : have: (...) -> Void - Fail.hx:7: characters 8-12 : want: (...) -> haxe.NotVoid -Fail.hx:8: characters 8-16 : error: FakeVoid should be haxe.NotVoid - Fail.hx:8: characters 8-16 : have: (...) -> FakeVoid - Fail.hx:8: characters 8-16 : want: (...) -> haxe.NotVoid diff --git a/tests/misc/projects/Issue6810/logfile-01-fail.hxml b/tests/misc/projects/Issue6810/logfile-01-fail.hxml deleted file mode 100644 index 1ba225d1ca9..00000000000 --- a/tests/misc/projects/Issue6810/logfile-01-fail.hxml +++ /dev/null @@ -1,2 +0,0 @@ --D message.log-file=logfile-02-fail.hxml.stderr -compile-fail.hxml diff --git a/tests/misc/projects/Issue6810/logfile-02-fail.hxml b/tests/misc/projects/Issue6810/logfile-02-fail.hxml deleted file mode 100644 index 693d7254560..00000000000 --- a/tests/misc/projects/Issue6810/logfile-02-fail.hxml +++ /dev/null @@ -1,4 +0,0 @@ --D message.log-file=logfile-03-fail.hxml.stderr --D message.log-format=pretty --D message.reporting=indent -compile-fail.hxml diff --git a/tests/misc/projects/Issue6810/logfile-03-fail.hxml b/tests/misc/projects/Issue6810/logfile-03-fail.hxml deleted file mode 100644 index 384c2aaf82d..00000000000 --- a/tests/misc/projects/Issue6810/logfile-03-fail.hxml +++ /dev/null @@ -1,4 +0,0 @@ --D message.log-file=logfile-04-fail.hxml.stderr --D message.log-format=classic --D message.reporting=pretty -compile-fail.hxml diff --git a/tests/misc/projects/Issue6810/logfile-04-fail.hxml b/tests/misc/projects/Issue6810/logfile-04-fail.hxml deleted file mode 100644 index cd2549fd132..00000000000 --- a/tests/misc/projects/Issue6810/logfile-04-fail.hxml +++ /dev/null @@ -1 +0,0 @@ -compile-fail.hxml diff --git a/tests/misc/projects/Issue6810/pretty-fail.hxml b/tests/misc/projects/Issue6810/pretty-fail.hxml deleted file mode 100644 index 7772625b58c..00000000000 --- a/tests/misc/projects/Issue6810/pretty-fail.hxml +++ /dev/null @@ -1,3 +0,0 @@ -compile-fail.hxml --D message.reporting=pretty --D message.no-color diff --git a/tests/misc/projects/Issue6810/pretty-fail.hxml.stderr b/tests/misc/projects/Issue6810/pretty-fail.hxml.stderr deleted file mode 100644 index f67eb44946b..00000000000 --- a/tests/misc/projects/Issue6810/pretty-fail.hxml.stderr +++ /dev/null @@ -1,16 +0,0 @@ -[ERROR] Fail.hx:7: characters 8-12 - - 7 | test(void); - | ^^^^ - | error: Void should be haxe.NotVoid - | have: (...) -> Void - | want: (...) -> haxe.NotVoid - -[ERROR] Fail.hx:8: characters 8-16 - - 8 | test(fakeVoid); - | ^^^^^^^^ - | error: FakeVoid should be haxe.NotVoid - | have: (...) -> FakeVoid - | want: (...) -> haxe.NotVoid - diff --git a/tests/nullsafety/src/cases/TestStrict.hx b/tests/nullsafety/src/cases/TestStrict.hx index 49be574fa4b..8f7dfb4d389 100644 --- a/tests/nullsafety/src/cases/TestStrict.hx +++ b/tests/nullsafety/src/cases/TestStrict.hx @@ -842,7 +842,7 @@ class TestStrict { } } - static function recursiveTypedef_shouldNotCrashTheCompiler(a:Recursive, b:Recursive) { + static function recursiveTypedef_shouldNotCrashTheCompiler(a:Recursive, b:Recursive) { a = b; } diff --git a/tests/unit/src/unit/issues/Issue9678.hx b/tests/unit/src/unit/issues/Issue9678.hx index c2c44d9fd04..f187011a6a9 100644 --- a/tests/unit/src/unit/issues/Issue9678.hx +++ b/tests/unit/src/unit/issues/Issue9678.hx @@ -11,13 +11,20 @@ class Issue9678 extends unit.Test { eq(2, called); } - @:keep static function explicitVoidArg(arg:Void) {} + @:keep static function explicitVoidArg(arg:haxe.NoValue) {} #end } private class C { final v:T; - public function new(v:T) this.v = v; - public function next(f:()->S):C return new C(f()); - public function handle(cb:T->Void) {cb(v);} + + public function new(v:T) + this.v = v; + + public function next(f:() -> S):C + return new C(f()); + + public function handle(cb:T->Void) { + cb(v); + } }