summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Parser/Statement.hs3
-rw-r--r--test/asset/list/concat.et22
-rw-r--r--test/script/list.et17
3 files changed, 41 insertions, 1 deletions
diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs
index c0a85e5..67f2f88 100644
--- a/src/Parser/Statement.hs
+++ b/src/Parser/Statement.hs
@@ -55,7 +55,8 @@ forStatement = do
wsymbol "in"
loff <- stateOffset <$> getParserState
- SomeExpr e <- someExpr FunctionTerm
+ tvar <- newTypeVar
+ SomeExpr e <- unifySomeExpr loff (ExprTypeApp (ExprTypeConstr1 (Proxy :: Proxy [])) [ ExprTypeVar tvar ]) =<< someExpr FunctionTerm
let err = parseError $ FancyError loff $ S.singleton $ ErrorFail $ T.unpack $
"expected a list, expression has type '" <> textExprType e <> "'"
ExprListUnpacker unpack _ <- maybe err return $ exprListUnpacker e
diff --git a/test/asset/list/concat.et b/test/asset/list/concat.et
index 8248cdc..613df57 100644
--- a/test/asset/list/concat.et
+++ b/test/asset/list/concat.et
@@ -3,6 +3,28 @@ test Test:
let list2 = [ 2, 3 ]
let empty = [ ]
+ node n
+
let c1 = concat [[ 1 ]]
+ for i in c1:
+ shell on n:
+ echo "c1 $i"
+ local:
+ shell on n:
+ echo "c1-end"
+
let c2 = concat [[ 1 ], [], empty]
+ for i in c2:
+ shell on n:
+ echo "c2 $i"
+ local:
+ shell on n:
+ echo "c2-end"
+
let c3 = concat [ list1, list2, [ 6, 5 ], list2 ]
+ for i in c3:
+ shell on n:
+ echo "c3 $i"
+ local:
+ shell on n:
+ echo "c3-end"
diff --git a/test/script/list.et b/test/script/list.et
index 8dcb4a8..a654111 100644
--- a/test/script/list.et
+++ b/test/script/list.et
@@ -3,6 +3,10 @@ module list
asset scripts:
path: ../asset/list
+def expect_next_stdout (what) from p:
+ expect /child-stdout shell (.*)/ from p capture line
+ guard (line == what)
+
test ListConcat:
spawn as p
@@ -11,6 +15,19 @@ test ListConcat:
expect /load-done/
send "run Test"
+ expect_next_stdout from p:
+ "c1 1"
+ "c1-end"
+ "c2 1"
+ "c2-end"
+ "c3 1"
+ "c3 2"
+ "c3 3"
+ "c3 6"
+ "c3 5"
+ "c3 2"
+ "c3 3"
+ "c3-end"
local:
expect /(run-.*)/ capture done
guard (done == "run-done")