Fixed bug with mutable closures in interpret (not really --- up to closure recursion)

This commit is contained in:
Dmitry Boulytchev 2019-10-17 15:30:50 +03:00
parent 1d28f4af6b
commit dad4c35a80
5 changed files with 31 additions and 7 deletions

View file

@ -8,9 +8,9 @@ check: $(TESTS)
$(TESTS): %: %.expr
@echo $@
$(RC) $< && cat $@.input | ./$@ 2> /dev/null > $@.log && diff $@.log orig/$@.log
$(RC) $< && cat $@.input | ./$@ > $@.log && diff $@.log orig/$@.log
cat $@.input | $(RC) -i $< > $@.log && diff $@.log orig/$@.log
cat $@.input | $(RC) -s $< 2> /dev/null > $@.log && diff $@.log orig/$@.log
cat $@.input | $(RC) -s $< > $@.log && diff $@.log orig/$@.log
clean:
$(RM) test*.log *.s *~ $(TESTS)

View file

@ -0,0 +1,3 @@
> 1
800
800

19
regression/test068.expr Normal file
View file

@ -0,0 +1,19 @@
fun lazy (f) {
local flag = 0, value = 0;
return fun () {
if flag
then return value
else
value := f ();
flag := 1;
return value
fi
}
}
local l = lazy (fun () {write (1); return 800});
local x = read ();
write (l ());
write (l ())

1
regression/test068.input Normal file
View file

@ -0,0 +1 @@
5