Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,654 changes: 3,330 additions & 3,324 deletions BOOTSTRAP/cli.c

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ dev: install-production
#lm --showalloc SRC/unit-prop-core.lsts > out.txt
#lm --showalloc SRC/unit-ascript-core.lsts > out.txt
#lm --showalloc SRC/index.lsts > out.txt
lm tests/promises/typechecking/misc-linear-error-1.lsts
lm tests/promises/typechecking/misc-linear-error-1.lsts > out.txt
gcc tmp.c;
./a.out

build: compile-production
time env $(LSTSFLAGS) ./production --v23 --c -o deploy1.c SRC/index.lsts
Expand Down
2 changes: 2 additions & 0 deletions SRC/type-is-linear.lsts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

let .is-linear(tt: Type): Bool = non-zero(tt.slot(c"Phi::Id",1));
10 changes: 8 additions & 2 deletions SRC/typecheck-infer-expr.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
(let tctx-cond, let new-cond) = std-infer-expr(tctx, cond, false, Tail(), ta);
(tctx-t, let new-t) = std-infer-expr(tctx-cond, t, false, Tail(), ta);
(tctx-f, let new-f) = std-infer-expr(tctx, f, false, Tail(), ta);
if typeof-term(new-t).is-t(c"Nil",0) and typeof-term(new-f).is-linear
then (tctx-f, new-f) = wrap-call(tctx-f, c".release", new-f);
if typeof-term(new-f).is-t(c"Nil",0) and typeof-term(new-t).is-linear
then (tctx-t, new-t) = wrap-call(tctx-t, c".release", new-t);
if not(is(cond,new-cond)) or not(is(t,new-t)) or not(is(f,new-f))
then { cond = new-cond; t = new-t; f = new-f; term = mk-app(mk-app(mk-app(ifv,new-cond),new-t),new-f) };
tctx = tctx.with-pctx( phi-merge(tctx,tctx-t.get-or(mk-tctx()).pctx,tctx-f.get-or(mk-tctx()).pctx,term) );
Expand All @@ -151,6 +155,10 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
(tctx-t, let new-t) = std-infer-expr(tctx, t, false, Tail(), ta);
(tctx-f, let new-f) = std-infer-expr(tctx, f, false, Tail(), ta);
(tctx-f, new-f) = release-locals(tctx, tctx-f, new-f, hint, false);
if typeof-term(new-t).is-t(c"Nil",0) and typeof-term(new-f).is-linear
then (tctx-f, new-f) = wrap-call(tctx-f, c".release", new-f);
if typeof-term(new-f).is-t(c"Nil",0) and typeof-term(new-t).is-linear
then (tctx-t, new-t) = wrap-call(tctx-t, c".release", new-t);
tctx = tctx-t;
if not(is(cond,new-cond)) or not(is(t,new-t)) or not(is(f,new-f))
then { cond = new-cond; t = new-t; f = new-f; term = mk-app(mk-app(mk-app(ifv,new-cond),new-t),new-f) };
Expand All @@ -173,8 +181,6 @@ let std-infer-expr(tctx: Maybe<TypeContext>, term: AST, is-scoped: Bool, used: I
};
if non-zero(term-phi-id) and term-phi-id != t-phi-id then tctx = tctx.phi-move(typeof-term(t), t);
if non-zero(term-phi-id) and term-phi-id != f-phi-id then tctx = tctx.phi-move(typeof-term(f), f);
if (typeof-term(term).is-t(c"Nil",0) or typeof-term(term).is-t(c"Never",0)) and non-zero(t-phi-id) then tctx = tctx.phi-move(typeof-term(t), t);
if (typeof-term(term).is-t(c"Nil",0) or typeof-term(term).is-t(c"Never",0)) and non-zero(f-phi-id) then tctx = tctx.phi-move(typeof-term(f), f);
}
);
ASTEOF{} => tctx = tctx.ascript(term, t0(c"Nil"));
Expand Down
1 change: 1 addition & 0 deletions SRC/unit-type-core.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ import SRC/type-cons-tail-or-self.lsts;
import SRC/type-without-modifiers.lsts;
import SRC/type-with-only-phi.lsts;
import SRC/type-reify-type-variables.lsts;
import SRC/type-is-linear.lsts;
10 changes: 10 additions & 0 deletions tests/promises/typechecking/misc-linear-error-1.lsts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,13 @@ import lib/core/bedrock.lsts;
let f(): Nil = (
if true then "";
);

let g(): Nil = (
if false then () else "";
);

f();
assert( safe-alloc-block-count == 0 );

g();
assert( safe-alloc-block-count == 0 );
Loading