-
Notifications
You must be signed in to change notification settings - Fork 375
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
fix: custom boolean types in conditional statements #2147
fix: custom boolean types in conditional statements #2147
Conversation
Hey, sorry for the wait. I'll take a look today! |
e41ba0a
to
d77e3c6
Compare
Note: currently looking into why |
bf5d7e5
to
20be919
Compare
It seems like the expression can be nil, like in |
gnovm/pkg/gnolang/preprocess.go
Outdated
convertConst(store, last, cx, BoolType) | ||
} else if x != nil { | ||
t := evalStaticTypeOf(store, last, x) | ||
checkType(baseOf(t), BoolType, false) |
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.
checkOrConvertIntegerType calls checkOrConvertType here, I wonder why there is asymmetry, and if we need it.
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.
also take a look at this, which I haven't reviewed; it makes changes to dependent functions.
#1426
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.
checkOrConvertIntegerType is calling checkIntegerType here:
gno/gnovm/pkg/gnolang/preprocess.go
Lines 3017 to 3024 in 80c9ddc
func checkOrConvertIntegerType(store Store, last BlockNode, x Expr) { | |
if cx, ok := x.(*ConstExpr); ok { | |
convertConst(store, last, cx, IntType) | |
} else if x != nil { | |
xt := evalStaticTypeOf(store, last, x) | |
checkIntegerType(xt) | |
} | |
} |
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.
also take a look at this, which I haven't reviewed; it makes changes to dependent functions. #1426
I think checkType
would have to be changed to assertAssignableTo
after that PR merges. I added a comment noting this
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #2147 +/- ##
=======================================
Coverage 54.61% 54.61%
=======================================
Files 582 582
Lines 78372 78372
=======================================
Hits 42801 42801
Misses 32360 32360
Partials 3211 3211
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
thank you! modified to use new functions. |
Resolves #1087
Preprocess conditional expr with
checkOrConvertBoolType
Unit test for
if
andfor
condition andinteg
test for invalid assignment. The invalid assignment is a case that fails to compile in Go, but succeeded in Gno before this change.Run tests:
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description