Skip to content

Commit 22a168d

Browse files
committed
that test passes now, lets see what happens for the big test
1 parent 009c651 commit 22a168d

4 files changed

Lines changed: 19 additions & 11 deletions

File tree

LM23COMMON/typecheck-infer-ctx.lsts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
let infer-ctx(tctx: TypeContext?, lhs: AST): TypeContext? = (
33
match lhs {
44
App{ left:Lit{key:c":"}, right:App{ v-t=left:Var{v1=key,vtk=token}, right:AType{tt=tt} } } => (
5-
(tctx, tt) = tctx.phi-initialize(tt, lhs);
6-
let dt = denormalize(tt) && t0(c"LocalVariable");
7-
let nt = tt.normalize;
5+
let dt = denormalize(tt.rewrite-type-alias.expand-implied-phi) && t0(c"LocalVariable");
6+
(tctx, dt) = tctx.phi-initialize(dt, lhs);
7+
let nt = dt.normalize;
88
tctx = infer-tctx(tctx.bind(v1, nt, dt, v-t), tt);
99
);
1010
App{ ps=left, right:App{ left:Lit{key:c":"}, right:App{ v-t=left:Var{v2=key,vtk=token}, right:AType{tt=tt} } } } => (
11-
(tctx, tt) = tctx.phi-initialize(tt, lhs);
12-
let dt = denormalize(tt) && t0(c"LocalVariable");
13-
let nt = tt.normalize;
11+
let dt = denormalize(tt.rewrite-type-alias.expand-implied-phi) && t0(c"LocalVariable");
12+
(tctx, dt) = tctx.phi-initialize(dt, lhs);
13+
let nt = dt.normalize;
1414
tctx = infer-tctx(infer-ctx(tctx.bind(v2, nt, dt, v-t),ps), tt);
1515
);
1616
ASTNil{} => ();

LM23COMMON/typecheck-infer-expr.lsts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
102102
);
103103
App{asc=left:Var{key:c"as"}, right:App{t=left,right:AType{tt=tt}}} => (
104104
let original-tt = tt;
105-
tt = tt.rewrite-type-alias;
105+
tt = tt.rewrite-type-alias.expand-implied-phi;
106106
add-concrete-type-instance(tt, term);
107107
(tctx, let new-t) = std-infer-expr(tctx, t, false, used, tt && hint);
108108
if not(is(t,new-t)) then { t = new-t; term = mk-app(asc, mk-app(t, mk-atype(tt))); };
@@ -246,6 +246,7 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
246246
let before-tctx = tctx; # make sure to capture locals as "local" scope
247247
tctx = infer-ctx(tctx, lhs);
248248
if not(inner-rhs.is-nil) {
249+
return-type = return-type.rewrite-type-alias.expand-implied-phi;
249250
(tctx, let new-inner-rhs) = std-infer-expr(tctx, inner-rhs, false, Tail(), return-type && t0(c"TailPosition"));
250251
if not(direct-tctx.is-blob) {
251252
let return-type-after-alias = return-type.rewrite-type-alias;

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ let lsts-parse-ascript(tokens: List<Token>): Tuple<AST,List<Token>> = (
609609
tokens = tail(tokens);
610610
(let tt, tokens) = lsts-parse-type(tokens);
611611
if tt.is-t(c"L",0) then tt = tt && t0(c"Literal");
612-
tt = phi-as-state(tt).expand-implied-phi;
612+
tt = phi-as-state(tt);
613613
match term {
614614
App{ constructor=left:Lit{}, right:ASTNil{} } => (
615615
term = mk-app(constructor.ascript(tt), mk-nil());
@@ -1003,7 +1003,7 @@ let lsts-parse-function-signature(fname: CString, tokens: List<Token>, loc: Sour
10031003
had-type = true;
10041004
lsts-parse-expect(c":", tokens); tokens = tail(tokens);
10051005
(arg-type, tokens) = lsts-parse-type(tokens);
1006-
if fname!=c"phi" then arg-type = phi-as-state(arg-type).expand-implied-phi;
1006+
if fname!=c"phi" then arg-type = phi-as-state(arg-type);
10071007
};
10081008
if lsts-parse-head(tokens)==c"," { tokens = tail(tokens); } else { lsts-parse-expect(c")", tokens); };
10091009
let arg-binding = if had-type then mk-cons(
@@ -1024,7 +1024,7 @@ let lsts-parse-function-signature(fname: CString, tokens: List<Token>, loc: Sour
10241024
lsts-parse-expect(c":", tokens); tokens = tail(tokens);
10251025
let rtype-rest = lsts-parse-type(tokens);
10261026
out.return-type = rtype-rest.first;
1027-
if fname!=c"phi" then out.return-type = phi-as-state(out.return-type).expand-implied-phi;
1027+
if fname!=c"phi" then out.return-type = phi-as-state(out.return-type);
10281028
tokens = rtype-rest.second;
10291029
} else if non-zero(out.args-type) {
10301030
out.return-type = t0(c"Nil");
@@ -2049,7 +2049,7 @@ let lsts-parse-atom-tail(base: AST, tokens: List<Token>): Tuple<AST,List<Token>>
20492049
tokens = type-rest.second;
20502050
base = mk-app(
20512051
Var( c"as", with-location(mk-token("as"),loc) ),
2052-
mk-cons(base, mk-atype(phi-as-state(type-rest.first).expand-implied-phi))
2052+
mk-cons(base, mk-atype(phi-as-state(type-rest.first)))
20532053
);
20542054
);
20552055
[Token{key:"["}.. rest] => (

tests/promises/typechecking/phi-on-alias.lsts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,10 @@ let f(ctx: AContext): Nil = (
99

1010
# just referencing the aliased List leads to a GC bug
1111
# because no phi state is inferred for the AContext
12+
13+
# can also be a problem on return values
14+
15+
let g(ctx: AContext): AContext = ctx;
16+
let h(ctx: AContext): Nil = (
17+
h(ctx); ()
18+
);

0 commit comments

Comments
 (0)