Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/logrusorgru/aurora/v4 v4.0.0
github.com/onflow/atree v0.10.1
github.com/onflow/crypto v0.25.3
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326
github.com/onflow/fixed-point v0.1.0
github.com/rivo/uniseg v0.4.7
github.com/schollz/progressbar/v3 v3.18.0
github.com/stretchr/testify v1.10.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -253,8 +253,8 @@ github.com/onflow/atree v0.10.1 h1:8sixWP3l3LitcyuKkVepbIsLbfr7JN3cCB/iA1j2JD8=
github.com/onflow/atree v0.10.1/go.mod h1:+BuiL0XuIigHJqwkdIuDNzxXvyDx1jYUog/w+iZhcE8=
github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326 h1:WgHDYQo283gJadQElJ8e6K9wiAsNL6F7npDnE1DisLA=
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326/go.mod h1:gJdoHqKtToKdOZbvryJvDZfcpzC7d2fyWuo3ZmLtcGY=
github.com/onflow/fixed-point v0.1.0 h1:ez9rXM/1DbhxxyCwWX7TDpS/pla/0ynOp3R3Y3CR5+c=
github.com/onflow/fixed-point v0.1.0/go.mod h1:gJdoHqKtToKdOZbvryJvDZfcpzC7d2fyWuo3ZmLtcGY=
github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
Expand Down
25 changes: 10 additions & 15 deletions interpreter/value_fix128.go
Original file line number Diff line number Diff line change
Expand Up @@ -629,18 +629,18 @@ func (v Fix128Value) ToBigInt() *big.Int {
}

func handleFixedpointError(err error, locationRange LocationRange) {
switch err {
switch err.(type) {
// `fix.ErrUnderflow` happens when the value is within the range but is too small
// to be represented using the current bit-length.
// These should be treated as non-errors, and should return the truncated value
// (assumes that the value returned is already the truncated value).
case nil, fix.ErrUnderflow:
case nil, fix.UnderflowError:
return
case fix.ErrOverflow:
case fix.PositiveOverflowError:
panic(&OverflowError{
LocationRange: locationRange,
})
case fix.ErrNegOverflow:
case fix.NegativeOverflowError:
panic(&UnderflowError{
LocationRange: locationRange,
})
Expand All @@ -653,20 +653,15 @@ func fix128SaturationArithmaticResult(
result fix.Fix128,
err error,
) fix.Fix128 {
if err == nil {
return result
}

// Should not panic on overflow/underflow.

// TODO: Switch on error type, rather than the value.
// Need changes to the fixedpoint library.
switch err {
case fix.ErrOverflow:
switch err.(type) {
case nil:
return result
case fix.PositiveOverflowError:
return fix.Fix128Max
case fix.ErrNegOverflow:
case fix.NegativeOverflowError:
return fix.Fix128Min
case fix.ErrUnderflow:
case fix.UnderflowError:
return fix.Fix128Zero
default:
panic(err)
Expand Down
17 changes: 6 additions & 11 deletions interpreter/value_ufix128.go
Original file line number Diff line number Diff line change
Expand Up @@ -625,20 +625,15 @@ func ufix128SaturationArithmaticResult(
result fix.UFix128,
err error,
) fix.UFix128 {
if err == nil {
return result
}

// Should not panic on overflow/underflow.

// TODO: Switch on error type, rather than the value.
// Need changes to the fixedpoint library.
switch err {
case fix.ErrOverflow:
switch err.(type) {
case nil:
return result
case fix.PositiveOverflowError:
return fixedpoint.UFix128TypeMax
case fix.ErrNegOverflow:
case fix.NegativeOverflowError:
return fixedpoint.UFix128TypeMin
case fix.ErrUnderflow:
case fix.UnderflowError:
return fix.UFix128Zero
default:
panic(err)
Expand Down
2 changes: 1 addition & 1 deletion tools/compatibility-check/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ require (
github.com/multiformats/go-varint v0.0.7 // indirect
github.com/onflow/atree v0.10.1 // indirect
github.com/onflow/crypto v0.25.3 // indirect
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326 // indirect
github.com/onflow/fixed-point v0.1.0 // indirect
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 // indirect
github.com/onflow/flow-ft/lib/go/contracts v1.0.1 // indirect
github.com/onflow/flow-ft/lib/go/templates v1.0.1 // indirect
Expand Down
4 changes: 2 additions & 2 deletions tools/compatibility-check/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,8 @@ github.com/onflow/atree v0.10.1 h1:8sixWP3l3LitcyuKkVepbIsLbfr7JN3cCB/iA1j2JD8=
github.com/onflow/atree v0.10.1/go.mod h1:+BuiL0XuIigHJqwkdIuDNzxXvyDx1jYUog/w+iZhcE8=
github.com/onflow/crypto v0.25.3 h1:XQ3HtLsw8h1+pBN+NQ1JYM9mS2mVXTyg55OldaAIF7U=
github.com/onflow/crypto v0.25.3/go.mod h1:+1igaXiK6Tjm9wQOBD1EGwW7bYWMUGKtwKJ/2QL/OWs=
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326 h1:WgHDYQo283gJadQElJ8e6K9wiAsNL6F7npDnE1DisLA=
github.com/onflow/fixed-point v0.0.0-20250828224344-9e339b60b326/go.mod h1:gJdoHqKtToKdOZbvryJvDZfcpzC7d2fyWuo3ZmLtcGY=
github.com/onflow/fixed-point v0.1.0 h1:ez9rXM/1DbhxxyCwWX7TDpS/pla/0ynOp3R3Y3CR5+c=
github.com/onflow/fixed-point v0.1.0/go.mod h1:gJdoHqKtToKdOZbvryJvDZfcpzC7d2fyWuo3ZmLtcGY=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0 h1:R86HaOuk6vpuECZnriEUE7bw9inC2AtdSn8lL/iwQLQ=
github.com/onflow/flow-core-contracts/lib/go/contracts v1.4.0/go.mod h1:9asTBnB6Tw2UlVVtQKyS/egYv3xr4zVlJnJ75z1dfac=
github.com/onflow/flow-core-contracts/lib/go/templates v1.3.3-0.20241017220455-79fdc6c8ba53 h1:swCMX7k//QjHatAZ3URX4GhfUWmLc6S/tmaw2mS/0ZU=
Expand Down