-
Notifications
You must be signed in to change notification settings - Fork 106
Fix empty list translation #1224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
src-tool/Pact/Analyze/Translate.hs
Outdated
-- rs (2023-05-10): Note, we handle the empty list properly (see #1182) | ||
-- as the element type is otherwise inferred as `Any`. | ||
AST_List node [] -> translateType node >>= \case | ||
EType retTy -> case retTy of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called retTy
here? What is node
at this point?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
retTy
is the return type of the translation step, i.e. SList SStr
. I will change it to listTy
.
The node
is of type Node
from the Typecheck module, see here. For the particular example above, its TyList {_tyListType = TyPrim TyString}
.
Need answer to a question first, I realized
Co-authored-by: Greg Hale <[email protected]>
The |
@@ -4564,3 +4564,11 @@ spec = describe "analyze" $ do | |||
(enforce false "")) | |||
|] | |||
"Vacuous property encountered!" | |||
|
|||
describe "regression #1182" $ do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be nice for the description to be self-contained.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thank you for the regression.
Fixes #1182
Prior this PR, the following code
ended in a execution error (Z3 error):
The reason for this behavior is the way we handle the empty list inside
mkLiteralList
, which returns a list literal of typeAny
for the empty list.With the proposed changes, the verification passes as expected:
PR checklist:
cabal run tests
. If they pass locally, docs are generated.pact -t
), make sure pact-lsp is in sync.Additionally, please justify why you should or should not do the following: