Skip to content

Commit b36ef3e

Browse files
authored
Fix empty list translation (#1224)
1 parent f4af428 commit b36ef3e

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src-tool/Pact/Analyze/Translate.hs

+7
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,13 @@ translateNode astNode = withAstContext astNode $ case astNode of
15141514

15151515
AST_NFun node "list" _ -> throwError' $ DeprecatedList node
15161516

1517+
-- rs (2023-05-10): Note, we handle the empty list as a special case (see #1182)
1518+
-- as the element type is otherwise inferred as `Any`.
1519+
AST_List node [] -> translateType node >>= \case
1520+
EType listTy -> case listTy of
1521+
SList _ -> pure $ Some listTy $ CoreTerm $ Lit []
1522+
_ -> throwError' $ TypeError node
1523+
15171524
AST_List node elems -> do
15181525
elems' <- traverse translateNode elems
15191526
Some ty litList <- mkLiteralList elems' ?? TypeError node

tests/AnalyzeSpec.hs

+7
Original file line numberDiff line numberDiff line change
@@ -4565,6 +4565,13 @@ spec = describe "analyze" $ do
45654565
|]
45664566
"Vacuous property encountered!"
45674567

4568+
describe "regression #1182" $ do
4569+
expectVerified [text|
4570+
(defun test:[string] (x: [string])
4571+
@model [(property (= x x))]
4572+
(let ((default-val:[string] [])) default-val)
4573+
x)
4574+
|]
45684575
describe "partial bind (regression #1173)" $ do
45694576
expectVerified [text|
45704577
(defschema ty

0 commit comments

Comments
 (0)