Skip to content

Commit

Permalink
[typer] remove check for extra fields on Const structures
Browse files Browse the repository at this point in the history
closes #3192
closes #9597
  • Loading branch information
Simn committed Jun 16, 2020
1 parent 49c5095 commit 889d7d1
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 deletions.
4 changes: 0 additions & 4 deletions src/core/tUnification.ml
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,6 @@ and unify_anons uctx a b a1 a2 =
| _ ->
error [has_no_field a n];
) a2.a_fields;
(match !(a1.a_status) with
| Const when not (PMap.is_empty a2.a_fields) ->
PMap.iter (fun n _ -> if not (PMap.mem n a2.a_fields) then error [has_extra_field a n]) a1.a_fields;
| _ -> ());
(match !(a2.a_status) with
| Statics c -> (match !(a1.a_status) with Statics c2 when c == c2 -> () | _ -> error [])
| EnumStatics e -> (match !(a1.a_status) with EnumStatics e2 when e == e2 -> () | _ -> error [])
Expand Down
4 changes: 1 addition & 3 deletions tests/misc/projects/Issue3192/compile1-fail.hxml.stderr
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
Main1.hx:3: characters 19-33 : { b : Int, a : Int } has extra field b
Main1.hx:3: characters 3-34 : { b : Int, a : Int } should be { a : Int }
Main1.hx:3: characters 3-34 : { b : Int, a : Int } has extra field b
Main1.hx:3: characters 19-33 : { b : Int, a : Int } has extra field b
2 changes: 1 addition & 1 deletion tests/unit/src/unit/issues/Issue3192.hx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Issue3192 extends Test {
var y1:{} = x1;
var y2:{} = x2;
var y3:{} = x3;
// var z1:{x:Int} = x1;
var z1:{x:Int} = x1;
var z2:{x:Int} = x2;
var z3:{x:Int} = x3;
eq(1, x1.x);
Expand Down
21 changes: 21 additions & 0 deletions tests/unit/src/unit/issues/Issue9597.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package unit.issues;
import unit.Test;

class Issue9597 extends Test {
function test() {
var data = [
{name: 'Page A', uv: 4000, pv: 2400, amt: 2400},
{name: 'Page B', uv: 3000, pv: 1398, amt: 2210},
{name: 'Page C', uv: -1000, pv: 9800, amt: 2290},
{name: 'Page D', uv: 500, pv: 3908, amt: 2000},
{name: 'Page E', uv: -2000, pv: 4800, amt: 2181},
{name: 'Page F', uv: -250, pv: 3800, amt: 2500},
{name: 'Page G', uv: 3490, pv: 4300, amt: 2100}
];

foo(data);
utest.Assert.pass();
}

static function foo<T:{uv:Int}>(data:Array<T>):Void {}
}

0 comments on commit 889d7d1

Please sign in to comment.