Skip to content

Commit 4c9a9fb

Browse files
committed
[Heavy] Fix tests for lists
1 parent 2fbd69e commit 4c9a9fb

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

heavy/lib/Mlir.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,17 @@ void create_op_impl(Context& C, ValueRefs Args) {
126126

127127
// operands
128128
for (heavy::Value V : Operands->getElements()) {
129+
// FIXME
130+
// Implicitly unwrapping lists here because
131+
// unquote-splicing is not implemented.
132+
if (isa<heavy::Pair, heavy::Empty>(V)) {
133+
for (heavy::Value V2 : V) {
134+
auto MVal = getTagged<mlir::Value>(C, kind::mlir_value, V2);
135+
if (!MVal)
136+
return C.RaiseError("expecting mlir.value", V2);
137+
OpState.operands.push_back(MVal);
138+
}
139+
}
129140
auto MVal = getTagged<mlir::Value>(C, kind::mlir_value, V);
130141
if (!MVal)
131142
return C.RaiseError("expecting mlir.value", V);

heavy/test/Evaluate/list.scm

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
(import (heavy base))
33

44
; CHECK: (1 2 "yo")
5-
; COM:CHECK: (1 2 . "yo")
65
(write (list 1 2 "yo"))(newline)
76

87
(define nums (list 1 2 3))
@@ -34,33 +33,48 @@
3433
(write nums)(newline)
3534

3635
;; List Formals
37-
; CHECK-NEXT #t
36+
; CHECK-NEXT: #t
3837
(write
3938
((lambda args
4039
(null? args))))
4140
(newline)
4241

43-
; CHECK-NEXT (1 2 4 5 6)
42+
; CHECK-NEXT: (1 2 4 5 6)
4443
(write
4544
((lambda args
4645
args)
4746
1 2 4 5 6))
4847
(newline)
4948

50-
; CHECK-NEXT (foo bar 4 5 6)
49+
; CHECK-NEXT: #(1 ())
50+
(write
51+
((lambda (arg . args)
52+
#(arg args))
53+
1))
54+
(newline)
55+
56+
; CHECK-NEXT: #(1 (2))
57+
(write
58+
((lambda (arg . args)
59+
#(arg args))
60+
1 2))
61+
(newline)
62+
63+
; CHECK-NEXT: (foo bar 4 5 6)
5164
(write
5265
((lambda (foo . bar)
5366
(append foo bar))
5467
'(foo bar) 4 5 6))
5568
(newline)
56-
; CHECK-NEXT (foo bar 4 5 6)
69+
70+
; CHECK-NEXT: (foo bar 4 5 6)
5771
(write
5872
((lambda (foo . bar)
5973
(append foo bar))
6074
'(foo bar) 4 5 6))
6175
(newline)
6276

63-
; CHECK-NEXT (foo bar 4 5 6)
77+
; CHECK-NEXT: (foo bar 4 5 6)
6478
(write
6579
((lambda (foo bar . baz)
6680
(append foo (list bar) baz))

0 commit comments

Comments
 (0)