Fix makeLiteral for arrays inside records.
This was an "obvious" bug (a missing pattern) being masked by me doing a pattern match inside an array constructor -- if the pattern doesn't match then it'll skip that value, rather than causing an error like it does in a case.
This commit is contained in:
parent
fad699421a
commit
82df59dcfb
|
@ -684,8 +684,11 @@ makeLiteral x@(A.Literal m t lr) wantT
|
||||||
-- representation.
|
-- representation.
|
||||||
(A.Record _, A.ArrayLiteral ml aes) ->
|
(A.Record _, A.ArrayLiteral ml aes) ->
|
||||||
do fs <- recordFields m underT
|
do fs <- recordFields m underT
|
||||||
es <- sequence [makeLiteral e t
|
es <- sequence [case ae of
|
||||||
| ((_, t), A.ArrayElemExpr e) <- zip fs aes]
|
A.ArrayElemExpr e -> makeLiteral e t
|
||||||
|
A.ArrayElemArray aes ->
|
||||||
|
makeLiteral (A.Literal m t $ A.ArrayLiteral ml aes) t
|
||||||
|
| ((_, t), ae) <- zip fs aes]
|
||||||
return $ A.Literal m wantT (A.RecordLiteral ml es)
|
return $ A.Literal m wantT (A.RecordLiteral ml es)
|
||||||
-- Some other kind of literal (one of the trivial types).
|
-- Some other kind of literal (one of the trivial types).
|
||||||
_ -> return $ A.Literal m wantT lr
|
_ -> return $ A.Literal m wantT lr
|
||||||
|
|
13
testcases/record-literals2.occ
Normal file
13
testcases/record-literals2.occ
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
-- From cgtest56
|
||||||
|
|
||||||
|
PROC record.literals()
|
||||||
|
DATA TYPE contains.array
|
||||||
|
RECORD
|
||||||
|
BYTE b :
|
||||||
|
[3]INT a :
|
||||||
|
INT i :
|
||||||
|
:
|
||||||
|
[2]contains.array aca :
|
||||||
|
aca := [['a', [2,3,4], 6],['b', [3,4,5], 7]]
|
||||||
|
:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user