diff --git a/frontends/ParseOccam.hs b/frontends/ParseOccam.hs index 9be3923..e23bb96 100644 --- a/frontends/ParseOccam.hs +++ b/frontends/ParseOccam.hs @@ -904,13 +904,20 @@ expression arrayConstructor :: OccParser A.Expression arrayConstructor - = do m <- md - sLeft - r <- replicator - sBar - e <- expression - sRight - return $ A.ExprConstr m $ A.RepConstr m r e + = do m <- md + sLeft + r <- replicator + sBar + r' <- scopeInRep r + ctx <- getTypeContext + subCtx <- case ctx of + Just t@(A.Array _ _) -> trivialSubscriptType m t >>* Just + _ -> return Nothing + e <- inTypeContext subCtx expression + scopeOutRep r' + sRight + return $ A.ExprConstr m $ A.RepConstr m r' e + "array constructor expression" associativeOpExpression :: OccParser A.Expression associativeOpExpression diff --git a/testcases/array-constructor.occ b/testcases/array-constructor.occ new file mode 100644 index 0000000..a90e7be --- /dev/null +++ b/testcases/array-constructor.occ @@ -0,0 +1,7 @@ +PROC P () + VAL []INT array IS [1, 2, 3, 4]: + VAL []INT zeros IS [i = 0 FOR 20 | 0]: + VAL []INT nums IS [i = 0 FOR 20 | i]: + VAL []INT squares IS [i = 0 FOR 20 | i * i]: + SKIP +: