Skip to content

Commit

Permalink
typed const conversion validation
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-dambovaliev committed Nov 13, 2024
1 parent bd1d76e commit 9a614ed
Show file tree
Hide file tree
Showing 4 changed files with 215 additions and 7 deletions.
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/op_expressions.go
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,6 @@ func (m *Machine) doOpFuncLit() {
func (m *Machine) doOpConvert() {
xv := m.PopValue()
t := m.PopValue().GetType()
ConvertTo(m.Alloc, m.Store, xv, t)
ConvertTo(m.Alloc, m.Store, xv, t, false)
m.PushValue(*xv)
}
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/preprocess.go
Original file line number Diff line number Diff line change
Expand Up @@ -3601,7 +3601,7 @@ func convertConst(store Store, last BlockNode, cx *ConstExpr, t Type) {
setConstAttrs(cx)
} else if t != nil {
// e.g. a named type or uint8 type to int for indexing.
ConvertTo(nilAllocator, store, &cx.TypedValue, t)
ConvertTo(nilAllocator, store, &cx.TypedValue, t, true)
setConstAttrs(cx)
}
}
Expand Down
2 changes: 1 addition & 1 deletion gnovm/pkg/gnolang/values.go
Original file line number Diff line number Diff line change
Expand Up @@ -1201,7 +1201,7 @@ func (tv *TypedValue) SetInt(n int) {

func (tv *TypedValue) ConvertGetInt() int {
var store Store = nil // not used
ConvertTo(nilAllocator, store, tv, IntType)
ConvertTo(nilAllocator, store, tv, IntType, false)
return tv.GetInt()
}

Expand Down
Loading

0 comments on commit 9a614ed

Please sign in to comment.