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:
Adam Sampson 2007-08-23 22:07:01 +00:00
parent fad699421a
commit 82df59dcfb
2 changed files with 18 additions and 2 deletions

View File

@ -684,8 +684,11 @@ makeLiteral x@(A.Literal m t lr) wantT
-- representation.
(A.Record _, A.ArrayLiteral ml aes) ->
do fs <- recordFields m underT
es <- sequence [makeLiteral e t
| ((_, t), A.ArrayElemExpr e) <- zip fs aes]
es <- sequence [case ae of
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)
-- Some other kind of literal (one of the trivial types).
_ -> return $ A.Literal m wantT lr

View 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]]
: