Skip to content

Commit

Permalink
[typer] clean up field-level errors (#10896)
Browse files Browse the repository at this point in the history
  • Loading branch information
Simn authored Dec 21, 2022
1 parent 9824939 commit 34ecf0e
Show file tree
Hide file tree
Showing 22 changed files with 116 additions and 76 deletions.
2 changes: 1 addition & 1 deletion src/compiler/retyper.ml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let pair_class_field rctx ctx cctx fctx cf cff p =
)
| FVar(th,eo) | FProp(_,_,th,eo) ->
let th = Some (pair_type th cf.cf_type) in
let t = disable_typeloading rctx ctx (fun () -> load_variable_type_hint ctx eo (pos cff.cff_name) th) in
let t = disable_typeloading rctx ctx (fun () -> load_variable_type_hint ctx fctx eo (pos cff.cff_name) th) in
(fun () ->
cf.cf_type <- t;
TypeBinding.bind_var ctx cctx fctx cf eo;
Expand Down
140 changes: 85 additions & 55 deletions src/typing/typeloadFields.ml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tests/misc/projects/Issue10005/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:5: characters 16-24 : Only extern functions may be overloaded on this target
Main.hx:5: characters 16-24 : Invalid modifier: overload is only supported on extern functions
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue10426/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:6: characters 2-10 : Constructors cannot be abstract
Main.hx:6: characters 2-10 : Invalid modifier: abstract on constructor
7 changes: 7 additions & 0 deletions tests/misc/projects/Issue10881/Main.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
abstract SerArray<S>(Array<S>) {
public dynamic function onChange():Void {};
}

class Main {
static function main() {}
}
2 changes: 2 additions & 0 deletions tests/misc/projects/Issue10881/compile-fail.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--main Main
--interp
1 change: 1 addition & 0 deletions tests/misc/projects/Issue10881/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Main.hx:2: characters 2-44 : Invalid modifier: dynamic on method of abstract
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue6584/compile1-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main1.hx:2: characters 2-17 : v: Static final variable must be initialized
Main1.hx:2: characters 2-17 : Static final variable must be initialized
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue6903/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:6: lines 6-8 : opAssign: Assignment overloading is not supported
Main.hx:6: lines 6-8 : Assignment overloading is not supported
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue8173/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Main.hx:2: characters 2-7 : Static method cannot be final
Main.hx:2: characters 2-7 : Invalid modifier combination: final + static
Main.hx:9: lines 9-11 : Cannot override final constructor
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue8551/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:6: characters 2-7 : Macro abstract constructors are not supported
Main.hx:6: characters 2-7 : Invalid modifier: macro on abstract constructor
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue8828/compile1-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main1.hx:2: characters 2-8 : extern modifier is not allowed on enum abstract fields
Main1.hx:2: characters 2-8 : Invalid modifier: extern on field of enum abstract
4 changes: 2 additions & 2 deletions tests/misc/projects/Issue9014/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
Main.hx:3: characters 2-40 : foo: 'override' is not allowed on 'static' functions
Main.hx:4: characters 2-39 : bar: 'inline' is not allowed on 'dynamic' functions
Main.hx:3: characters 2-40 : Invalid modifier combination: override + static
Main.hx:4: characters 2-39 : Invalid modifier combination: dynamic + inline
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 2-52 : Abstract methods may not be dynamic
Main.hx:2: characters 2-52 : Invalid modifier combination: abstract + dynamic
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 26-42 : Abstract methods may not be final
Main.hx:2: characters 26-42 : Invalid modifier combination: abstract + final
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 34-50 : Abstract methods may not be inline
Main.hx:2: characters 34-50 : Invalid modifier combination: abstract + inline
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 27-43 : Static methods may not be abstract
Main.hx:2: characters 27-43 : Invalid modifier combination: abstract + static
2 changes: 1 addition & 1 deletion tests/misc/projects/Issue9785/compile-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 2-19 : x: Cannot declare member variable in abstract
Main.hx:2: characters 2-19 : Cannot declare member variable in abstract
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 2-10 : Only extern functions may be overloaded on this target
Main.hx:2: characters 2-10 : Invalid modifier: overload is only supported on extern functions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Main.hx:2: characters 2-10 : Constructors cannot be overloaded on this target
Main.hx:2: characters 2-10 : Invalid modifier: overload on constructor
6 changes: 3 additions & 3 deletions tests/misc/src/Main.hx
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ class Main {
.join('\n');

if (content != expected) {
println('Actual $name output doesn\'t match the expected one');
println('Expected:\n"$expected"');
println('Actual:\n"$content"');
println('Expected:\n$expected');
println('Actual:\n$content');
println('');
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/compile-each.hxml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
--resource serializedValues.txt
--macro Macro.init()
--dce full
-lib utest:git:https://github.com/haxe-utest/utest#559b24c9a36533281ba7a2eed8aab83ed6b872b4
-lib utest
-D analyzer-optimize
-D analyzer-user-var-fusion

0 comments on commit 34ecf0e

Please sign in to comment.