-
Notifications
You must be signed in to change notification settings - Fork 443
chore(gnovm): optimize err msg #4936
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -734,7 +734,10 @@ func (x *BinaryExpr) AssertCompatible(lt, rt Type) { | |
| case EQL, NEQ: | ||
| assertComparable(xt, dt) | ||
| if !isUntyped(xt) && !isUntyped(dt) { | ||
| assertAssignableTo(x, xt, dt) | ||
| err := checkAssignableTo(x, xt, dt) | ||
| if err != nil { | ||
| panic(fmt.Sprintf("invalid operation: %v (mismatched types %v and %v)", x, xt, dt)) | ||
| } | ||
|
Comment on lines
740
to
746
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we wrap the error in the panic message ? Also in if checkAssignableTo(n, tt, st) != nil {
panic(
fmt.Sprintf(
"cannot use %v (value of type %s) as %s value in assignment",
valueExpr.String(),
tt.String(),
st.String(),
),
)
}Also what about editing directly
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think the low-level message is useful for debugging, but not for end users. We should log it instead of returning. :51625b8
it looks the correct, see gnovm/tests/files/assign33.gno.
for me it still make sense that it provides lower-level infos. |
||
| } | ||
| case LSS, LEQ, GTR, GEQ: | ||
| if checker, ok := binaryChecker[x.Op]; ok { | ||
|
|
||
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.
security-wise, we should maybe avoid panicking with the whole expression, as it might be very deep. what about making the error "types %v and %v are not comparable"?