Skip to content

Commit f6431f7

Browse files
authored
Merge pull request #2076 from andrew4328/test-coverage-for-lsts-frontend-fixes-fdjksldsll
Test coverage for lsts frontend fixes fdjksldsll
2 parents e496439 + 0154587 commit f6431f7

15 files changed

Lines changed: 4542 additions & 4750 deletions

BOOTSTRAP/cli.c

Lines changed: 4387 additions & 4365 deletions
Large diffs are not rendered by default.

BOOTSTRAP/monolithic.lsts

Lines changed: 50 additions & 364 deletions
Large diffs are not rendered by default.

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ LSTSFLAGS = MALLOC_CHECK_=3
88
# recommendation: ulimit -s unlimited
99

1010
dev: install-production
11-
lm tests/promises/syntax/lhs-while-let.lsts
11+
lm tests/promises/syntax/lhs-nested-field-gc.lsts > out.txt
1212
gcc tmp.c
1313
./a.out
1414

PLUGINS/FRONTEND/LSTS/lsts-parse.lsts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,12 @@ let lsts-parse-typed-macro(tokens: List<Token>): (AST, List<Token>) = (
236236
lsts-parse-expect(c"typed", tokens); tokens = tail(tokens);
237237
lsts-parse-expect(c"macro", tokens); tokens = tail(tokens);
238238

239+
let misc-tt = ta;
240+
if lsts-parse-head(tokens)==c":" {
241+
lsts-parse-expect(c":", tokens); tokens = tail(tokens);
242+
(misc-tt, tokens) = lsts-parse-type(tokens);
243+
};
244+
239245
(let mname, tokens) = lsts-parse-identifier(tokens);
240246
let margs = mk-nil();
241247
lsts-parse-expect(c"(", tokens); tokens = tail(tokens);
@@ -273,7 +279,7 @@ let lsts-parse-typed-macro(tokens: List<Token>): (AST, List<Token>) = (
273279
lsts-parse-expect(c";", tokens); tokens = tail(tokens);
274280
(mk-glb(
275281
mk-token(mname),
276-
mk-abs(margs, mbody.without-location.ascript(mrett), t0(c"TypedMacro"))
282+
mk-abs(margs, mbody.without-location.ascript(mrett), t0(c"TypedMacro") && misc-tt)
277283
), tokens);
278284
);
279285

SRC/ast-misc-todo-remove-or-stabilize.lsts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,12 @@ type ApplyResult = { function-type:Type , return-type:Type };
1414
type CompileMode = ModeTokenize | ModeParse | ModePreprocess | ModeTypecheck | ModeCompile;
1515

1616
type IsUsed = Used | Unused | Tail | Call { function-name: CString };
17+
let .function-name(used: IsUsed): CString = (
18+
match used {
19+
Call{function-name=function-name} => function-name;
20+
_ => c"";
21+
}
22+
);
1723
let .is-call(used: IsUsed): Bool = (
1824
match used {
1925
Call{} => true;

SRC/type-constructor.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ let interned-tag-must-not-rewrite = intern-type-tag(c"MustNotRewrite");
3535
let interned-tag-vararg = intern-type-tag(c"...");
3636
let interned-tag-any = intern-type-tag(c"Any");
3737
let interned-tag-nil = intern-type-tag(c"Nil");
38+
let interned-tag-lazy = intern-type-tag(c"Lazy");
3839
let interned-tag-typedef = intern-type-tag(c"typedef");
3940
let interned-tag-tail-position = intern-type-tag(c"TailPosition");
4041
let interned-tag-const = intern-type-tag(c"const");

SRC/typecheck-infer-expr.lsts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,7 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
316316
# TailPosition LocalVariables don't need to be retained because +1/-1 retain/release cancels itself out
317317
if not(hint.is-t(interned-tag-tail-position,0) and vt.is-t(interned-tag-local-variable,0))
318318
and not(hint.is-t(interned-tag-must-not-retain,0))
319+
and not(used.function-name.is-lazy-macro)
319320
and not(tctx.get-or(mk-tctx()).is-blob) {
320321
tctx = tctx.ascript(term, vt);
321322
(tctx, term) = maybe-retain(tctx, term);
@@ -543,5 +544,7 @@ let std-infer-call-arg(tctx: TypeContext?, term: AST, function-name: CString, hi
543544
(tctx, term)
544545
);
545546
_ => (tctx, term);
546-
}} else std-infer-expr(tctx, term, false, Call(function-name), hint);
547+
}} else {
548+
std-infer-expr(tctx, term, false, Call(function-name), hint);
549+
};
547550
);

SRC/typecheck-infer-global-terms.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ let infer-global-macro(term: AST): Nil = (
118118
for s in seq { infer-global-macro(s) };
119119
);
120120
Glb{ k=key, frhs=val:Abs{lhs=lhs, rhs:App{left:Lit{key:c":"}, right:App{rhs=left, right:AType{return-type=tt}}}, misc-tt=tt} } => (
121+
if misc-tt.is-t(interned-tag-lazy,0) then mark-is-lazy-macro(k.key);
121122
if misc-tt.is-t(interned-tag-typed-macro,0) then bind-new-macro(k.key, frhs)
122123
);
123124
_ => ();

SRC/typecheck-std-apply-macro.lsts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ let std-apply-macro(tctx: Maybe<TypeContext>, mname: CString, margs: AST, used:
9393
};
9494
};
9595
(let peeped-tctx, peeped-type, margs) = if not(is(strong,MacroSuperWeak)) {
96-
std-infer-peeped-arguments(tctx, margs, peep-holes, true);
96+
std-infer-peeped-arguments(tctx, mname, margs, peep-holes, true);
9797
} else {
98-
std-infer-peeped-arguments(tctx, margs, peep-holes, false);
98+
std-infer-peeped-arguments(tctx, mname, margs, peep-holes, false);
9999
};
100100
let peeped-tctx-unwrapped = peeped-tctx.get-or(mk-tctx());
101101
peeped-tctx-unwrapped.pctx = tctx.get-or(mk-tctx()).pctx; # Phi Variables are irrelevant to peeped arguments
@@ -127,13 +127,13 @@ let std-apply-macro(tctx: Maybe<TypeContext>, mname: CString, margs: AST, used:
127127

128128
if not(is(strong,MacroWeak) or is(strong,MacroSuperWeak)) and not(non-zero(result)) then exit-error("Failed to Apply Macro: \{mname}\nArgs: \{margs} : \{peeped-type}\n", margs);
129129
if is(strong,MacroTerm) {
130-
(tctx, result) = std-infer-expr(tctx, result, false, if return-type==type-lazy then used else Tail, ta);
130+
(tctx, result) = std-infer-expr(tctx, result, false, if mname.is-lazy-macro then Call(mname) else if return-type==type-lazy then used else Tail, ta);
131131
mark-free-and-seen(result);
132132
};
133133
(tctx, result)
134134
);
135135

136-
let std-infer-peeped-arguments(tctx: Maybe<TypeContext>, t: AST, peep: Type, strong: Bool): (TypeContext?, Type, AST) = (
136+
let std-infer-peeped-arguments(tctx: Maybe<TypeContext>, mname: CString, t: AST, peep: Type, strong: Bool): (TypeContext?, Type, AST) = (
137137
let o-t = t;
138138
let rewritten = false;
139139
match t {
@@ -159,8 +159,8 @@ let std-infer-peeped-arguments(tctx: Maybe<TypeContext>, t: AST, peep: Type, str
159159
TGround{tag:interned-tag-cons, parameters:[p2.. p1..]} => (
160160
match t {
161161
App{is-cons=is-cons, left=left, right=right} => (
162-
(tctx, let lt, let new-left) = std-infer-peeped-arguments(tctx, left, p1, strong);
163-
(tctx, let rt, let new-right) = std-infer-peeped-arguments(tctx, right, p2, strong);
162+
(tctx, let lt, let new-left) = std-infer-peeped-arguments(tctx, mname, left, p1, strong);
163+
(tctx, let rt, let new-right) = std-infer-peeped-arguments(tctx, mname, right, p2, strong);
164164
if not(is(left,new-left)) or not(is(right,new-right))
165165
then t = mk-cons-or-app(is-cons,new-left,new-right);
166166
(tctx, t2(interned-tag-cons,lt,rt), t)
@@ -172,7 +172,7 @@ let std-infer-peeped-arguments(tctx: Maybe<TypeContext>, t: AST, peep: Type, str
172172
_ => (
173173
if strong {
174174
if not rewritten {
175-
(let protected-tctx, t) = std-infer-expr(tctx, t, false, Used(), ta);
175+
(let protected-tctx, t) = std-infer-expr(tctx, t, false, if mname.is-lazy-macro then Call(mname) else Used(), ta);
176176
mark-free-and-seen(t);
177177
tctx = tctx.with-pctx( protected-tctx.get-or(mk-tctx()).pctx );
178178
};

SRC/unit-util.lsts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ import lib/core/bedrock.lsts;
44
let safe-alloc-block-count = 0;
55

66
import SRC/util-uuid.lsts;
7+
import SRC/util-is-lazy-macro.lsts;

0 commit comments

Comments
 (0)