From 48e73aa1a5be8a75f683df02a1b1a5448c4843da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 2 Aug 2023 17:06:56 -0700 Subject: [PATCH 1/4] remove unused code --- runtime/interpreter/location.go | 8 -------- 1 file changed, 8 deletions(-) diff --git a/runtime/interpreter/location.go b/runtime/interpreter/location.go index dc465a8a91..4186c84c3e 100644 --- a/runtime/interpreter/location.go +++ b/runtime/interpreter/location.go @@ -23,14 +23,6 @@ import ( "github.com/onflow/cadence/runtime/common" ) -// LocationPosition defines a position in the source of the import tree. -// The Location defines the script within the import tree, the Position -// defines the row/colum within the source of that script. -type LocationPosition struct { - Location common.Location - Position ast.Position -} - // LocationRange defines a range in the source of the import tree. // The Position defines the script within the import tree, the Range // defines the start/end position within the source of that script. From c373e388ad713e004d34c2519a39c945a43d96ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 2 Aug 2023 17:08:25 -0700 Subject: [PATCH 2/4] provide location ranges --- runtime/interpreter/value.go | 3502 +++++++++++++++++++++------------- runtime/literal.go | 3 +- runtime/parser/errors.go | 1 + 3 files changed, 2152 insertions(+), 1354 deletions(-) diff --git a/runtime/interpreter/value.go b/runtime/interpreter/value.go index 6b11e3737a..1049ab84ea 100644 --- a/runtime/interpreter/value.go +++ b/runtime/interpreter/value.go @@ -258,9 +258,13 @@ type ValueIterator interface { func safeAdd(a, b int, locationRange LocationRange) int { // INT32-C if (b > 0) && (a > (goMaxInt - b)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (b < 0) && (a < (goMinInt - b)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return a + b } @@ -271,24 +275,32 @@ func safeMul(a, b int, locationRange LocationRange) int { if b > 0 { // positive * positive = positive. overflow? if a > (goMaxInt / b) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } else { // positive * negative = negative. underflow? if b < (goMinInt / a) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } } else { if b > 0 { // negative * positive = negative. underflow? if a < (goMinInt / b) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } else { // negative * negative = positive. overflow? if (a != 0) && (b < (goMaxInt / a)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } } @@ -674,7 +686,7 @@ func (v BoolValue) Equal(_ *Interpreter, _ LocationRange, other Value) bool { return bool(v) == bool(otherBool) } -func (v BoolValue) Less(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v BoolValue) Less(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { o, ok := other.(BoolValue) if !ok { panic(errors.NewUnreachableError()) @@ -683,7 +695,7 @@ func (v BoolValue) Less(interpreter *Interpreter, other ComparableValue, locatio return !v && o } -func (v BoolValue) LessEqual(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v BoolValue) LessEqual(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { o, ok := other.(BoolValue) if !ok { panic(errors.NewUnreachableError()) @@ -692,7 +704,7 @@ func (v BoolValue) LessEqual(interpreter *Interpreter, other ComparableValue, lo return !v || o } -func (v BoolValue) Greater(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v BoolValue) Greater(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { o, ok := other.(BoolValue) if !ok { panic(errors.NewUnreachableError()) @@ -701,7 +713,7 @@ func (v BoolValue) Greater(interpreter *Interpreter, other ComparableValue, loca return v && !o } -func (v BoolValue) GreaterEqual(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v BoolValue) GreaterEqual(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { o, ok := other.(BoolValue) if !ok { panic(errors.NewUnreachableError()) @@ -868,7 +880,7 @@ func (v CharacterValue) Equal(_ *Interpreter, _ LocationRange, other Value) bool return v.NormalForm() == otherChar.NormalForm() } -func (v CharacterValue) Less(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v CharacterValue) Less(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { otherChar, ok := other.(CharacterValue) if !ok { panic(errors.NewUnreachableError()) @@ -876,7 +888,7 @@ func (v CharacterValue) Less(interpreter *Interpreter, other ComparableValue, lo return v.NormalForm() < otherChar.NormalForm() } -func (v CharacterValue) LessEqual(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v CharacterValue) LessEqual(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { otherChar, ok := other.(CharacterValue) if !ok { panic(errors.NewUnreachableError()) @@ -884,7 +896,7 @@ func (v CharacterValue) LessEqual(interpreter *Interpreter, other ComparableValu return v.NormalForm() <= otherChar.NormalForm() } -func (v CharacterValue) Greater(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v CharacterValue) Greater(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { otherChar, ok := other.(CharacterValue) if !ok { panic(errors.NewUnreachableError()) @@ -892,7 +904,7 @@ func (v CharacterValue) Greater(interpreter *Interpreter, other ComparableValue, return v.NormalForm() > otherChar.NormalForm() } -func (v CharacterValue) GreaterEqual(interpreter *Interpreter, other ComparableValue, locationRange LocationRange) BoolValue { +func (v CharacterValue) GreaterEqual(_ *Interpreter, other ComparableValue, _ LocationRange) BoolValue { otherChar, ok := other.(CharacterValue) if !ok { panic(errors.NewUnreachableError()) @@ -1099,9 +1111,10 @@ func (v *StringValue) Less(interpreter *Interpreter, other ComparableValue, loca otherString, ok := other.(*StringValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -1112,9 +1125,10 @@ func (v *StringValue) LessEqual(interpreter *Interpreter, other ComparableValue, otherString, ok := other.(*StringValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -1125,9 +1139,10 @@ func (v *StringValue) Greater(interpreter *Interpreter, other ComparableValue, l otherString, ok := other.(*StringValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -1138,9 +1153,10 @@ func (v *StringValue) GreaterEqual(interpreter *Interpreter, other ComparableVal otherString, ok := other.(*StringValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3176,7 +3192,9 @@ func (IntValue) IsImportable(_ *Interpreter) bool { func (v IntValue) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -3208,7 +3226,7 @@ func (v IntValue) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferences return v.String() } -func (v IntValue) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { +func (v IntValue) Negate(interpreter *Interpreter, _ LocationRange) NumberValue { return NewIntValueFromBigInt( interpreter, common.NewNegateBigIntMemoryUsage(v.BigInt), @@ -3222,9 +3240,10 @@ func (v IntValue) Plus(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3243,9 +3262,10 @@ func (v IntValue) SaturatingPlus(interpreter *Interpreter, other NumberValue, lo r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -3257,9 +3277,10 @@ func (v IntValue) Minus(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3278,9 +3299,10 @@ func (v IntValue) SaturatingMinus(interpreter *Interpreter, other NumberValue, l r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -3292,9 +3314,10 @@ func (v IntValue) Mod(interpreter *Interpreter, other NumberValue, locationRange o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3305,7 +3328,9 @@ func (v IntValue) Mod(interpreter *Interpreter, other NumberValue, locationRange res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Rem(v.BigInt, o.BigInt) }, @@ -3316,9 +3341,10 @@ func (v IntValue) Mul(interpreter *Interpreter, other NumberValue, locationRange o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3337,9 +3363,10 @@ func (v IntValue) SaturatingMul(interpreter *Interpreter, other NumberValue, loc r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -3351,9 +3378,10 @@ func (v IntValue) Div(interpreter *Interpreter, other NumberValue, locationRange o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3364,7 +3392,9 @@ func (v IntValue) Div(interpreter *Interpreter, other NumberValue, locationRange res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -3376,9 +3406,10 @@ func (v IntValue) SaturatingDiv(interpreter *Interpreter, other NumberValue, loc r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -3390,9 +3421,10 @@ func (v IntValue) Less(interpreter *Interpreter, other ComparableValue, location o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3404,9 +3436,10 @@ func (v IntValue) LessEqual(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3418,9 +3451,10 @@ func (v IntValue) Greater(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3433,9 +3467,10 @@ func (v IntValue) GreaterEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3475,9 +3510,10 @@ func (v IntValue) BitwiseOr(interpreter *Interpreter, other IntegerValue, locati o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3495,9 +3531,10 @@ func (v IntValue) BitwiseXor(interpreter *Interpreter, other IntegerValue, locat o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3515,9 +3552,10 @@ func (v IntValue) BitwiseAnd(interpreter *Interpreter, other IntegerValue, locat o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3535,18 +3573,23 @@ func (v IntValue) BitwiseLeftShift(interpreter *Interpreter, other IntegerValue, o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewIntValueFromBigInt( @@ -3563,18 +3606,23 @@ func (v IntValue) BitwiseRightShift(interpreter *Interpreter, other IntegerValue o, ok := other.(IntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewIntValueFromBigInt( @@ -3721,14 +3769,16 @@ func (v Int8Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReference return v.String() } -func (v Int8Value) ToInt(locationRange LocationRange) int { +func (v Int8Value) ToInt(_ LocationRange) int { return int(v) } func (v Int8Value) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { // INT32-C if v == math.MinInt8 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int8 { @@ -3742,17 +3792,22 @@ func (v Int8Value) Plus(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v > (math.MaxInt8 - o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v < (math.MinInt8 - o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int8 { @@ -3766,9 +3821,10 @@ func (v Int8Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3789,17 +3845,22 @@ func (v Int8Value) Minus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v < (math.MinInt8 + o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v > (math.MaxInt8 + o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int8 { @@ -3813,9 +3874,10 @@ func (v Int8Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3836,15 +3898,18 @@ func (v Int8Value) Mod(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() int8 { @@ -3858,9 +3923,10 @@ func (v Int8Value) Mul(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3869,24 +3935,32 @@ func (v Int8Value) Mul(interpreter *Interpreter, other NumberValue, locationRang if o > 0 { // positive * positive = positive. overflow? if v > (math.MaxInt8 / o) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } else { // positive * negative = negative. underflow? if o < (math.MinInt8 / v) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } } else { if o > 0 { // negative * positive = negative. underflow? if v < (math.MinInt8 / o) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } else { // negative * negative = positive. overflow? if (v != 0) && (o < (math.MaxInt8 / v)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } } @@ -3902,9 +3976,10 @@ func (v Int8Value) SaturatingMul(interpreter *Interpreter, other NumberValue, lo o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3946,18 +4021,23 @@ func (v Int8Value) Div(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt8) && (o == -1) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int8 { @@ -3971,9 +4051,10 @@ func (v Int8Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, lo o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -3981,7 +4062,9 @@ func (v Int8Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, lo // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt8) && (o == -1) { return math.MaxInt8 } @@ -3995,9 +4078,10 @@ func (v Int8Value) Less(interpreter *Interpreter, other ComparableValue, locatio o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4008,9 +4092,10 @@ func (v Int8Value) LessEqual(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4021,9 +4106,10 @@ func (v Int8Value) Greater(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4034,9 +4120,10 @@ func (v Int8Value) GreaterEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4067,18 +4154,26 @@ func ConvertInt8(memoryGauge common.MemoryGauge, value Value, locationRange Loca case BigNumberValue: v := value.ToBigInt(memoryGauge) if v.Cmp(sema.Int8TypeMaxInt) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int8TypeMinInt) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int8(v.Int64()) case NumberValue: v := value.ToInt(locationRange) if v > math.MaxInt8 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v < math.MinInt8 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int8(v) @@ -4094,9 +4189,10 @@ func (v Int8Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, locat o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4111,9 +4207,10 @@ func (v Int8Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4128,9 +4225,10 @@ func (v Int8Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4145,9 +4243,10 @@ func (v Int8Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValue o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4162,9 +4261,10 @@ func (v Int8Value) BitwiseRightShift(interpreter *Interpreter, other IntegerValu o, ok := other.(Int8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4310,14 +4410,16 @@ func (v Int16Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v Int16Value) ToInt(locationRange LocationRange) int { +func (v Int16Value) ToInt(_ LocationRange) int { return int(v) } func (v Int16Value) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { // INT32-C if v == math.MinInt16 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int16 { @@ -4331,17 +4433,22 @@ func (v Int16Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v > (math.MaxInt16 - o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v < (math.MinInt16 - o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int16 { @@ -4355,9 +4462,10 @@ func (v Int16Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4378,17 +4486,22 @@ func (v Int16Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v < (math.MinInt16 + o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v > (math.MaxInt16 + o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int16 { @@ -4402,9 +4515,10 @@ func (v Int16Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4425,15 +4539,18 @@ func (v Int16Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() int16 { @@ -4447,9 +4564,10 @@ func (v Int16Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4458,24 +4576,32 @@ func (v Int16Value) Mul(interpreter *Interpreter, other NumberValue, locationRan if o > 0 { // positive * positive = positive. overflow? if v > (math.MaxInt16 / o) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } else { // positive * negative = negative. underflow? if o < (math.MinInt16 / v) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } } else { if o > 0 { // negative * positive = negative. underflow? if v < (math.MinInt16 / o) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } else { // negative * negative = positive. overflow? if (v != 0) && (o < (math.MaxInt16 / v)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } } @@ -4491,9 +4617,10 @@ func (v Int16Value) SaturatingMul(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4534,18 +4661,23 @@ func (v Int16Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt16) && (o == -1) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int16 { @@ -4559,9 +4691,10 @@ func (v Int16Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4569,7 +4702,9 @@ func (v Int16Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt16) && (o == -1) { return math.MaxInt16 } @@ -4583,9 +4718,10 @@ func (v Int16Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4596,9 +4732,10 @@ func (v Int16Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4609,9 +4746,10 @@ func (v Int16Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4622,9 +4760,10 @@ func (v Int16Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4655,18 +4794,26 @@ func ConvertInt16(memoryGauge common.MemoryGauge, value Value, locationRange Loc case BigNumberValue: v := value.ToBigInt(memoryGauge) if v.Cmp(sema.Int16TypeMaxInt) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int16TypeMinInt) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int16(v.Int64()) case NumberValue: v := value.ToInt(locationRange) if v > math.MaxInt16 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v < math.MinInt16 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int16(v) @@ -4682,9 +4829,10 @@ func (v Int16Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4699,9 +4847,10 @@ func (v Int16Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4716,9 +4865,10 @@ func (v Int16Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4733,9 +4883,10 @@ func (v Int16Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValu o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4750,9 +4901,10 @@ func (v Int16Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Int16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4900,14 +5052,16 @@ func (v Int32Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v Int32Value) ToInt(locationRange LocationRange) int { +func (v Int32Value) ToInt(_ LocationRange) int { return int(v) } func (v Int32Value) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { // INT32-C if v == math.MinInt32 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int32 { @@ -4921,17 +5075,22 @@ func (v Int32Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v > (math.MaxInt32 - o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v < (math.MinInt32 - o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int32 { @@ -4945,9 +5104,10 @@ func (v Int32Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -4968,17 +5128,22 @@ func (v Int32Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v < (math.MinInt32 + o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v > (math.MaxInt32 + o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int32 { @@ -4992,9 +5157,10 @@ func (v Int32Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5015,15 +5181,18 @@ func (v Int32Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() int32 { @@ -5037,9 +5206,10 @@ func (v Int32Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5048,24 +5218,32 @@ func (v Int32Value) Mul(interpreter *Interpreter, other NumberValue, locationRan if o > 0 { // positive * positive = positive. overflow? if v > (math.MaxInt32 / o) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } else { // positive * negative = negative. underflow? if o < (math.MinInt32 / v) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } } else { if o > 0 { // negative * positive = negative. underflow? if v < (math.MinInt32 / o) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } else { // negative * negative = positive. overflow? if (v != 0) && (o < (math.MaxInt32 / v)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } } @@ -5081,9 +5259,10 @@ func (v Int32Value) SaturatingMul(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5124,18 +5303,23 @@ func (v Int32Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt32) && (o == -1) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int32 { @@ -5149,9 +5333,10 @@ func (v Int32Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5159,7 +5344,9 @@ func (v Int32Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt32) && (o == -1) { return math.MaxInt32 } @@ -5174,9 +5361,10 @@ func (v Int32Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5187,9 +5375,10 @@ func (v Int32Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5200,9 +5389,10 @@ func (v Int32Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5213,9 +5403,10 @@ func (v Int32Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5245,18 +5436,26 @@ func ConvertInt32(memoryGauge common.MemoryGauge, value Value, locationRange Loc case BigNumberValue: v := value.ToBigInt(memoryGauge) if v.Cmp(sema.Int32TypeMaxInt) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int32TypeMinInt) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int32(v.Int64()) case NumberValue: v := value.ToInt(locationRange) if v > math.MaxInt32 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v < math.MinInt32 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int32(v) @@ -5272,9 +5471,10 @@ func (v Int32Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5289,9 +5489,10 @@ func (v Int32Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5306,9 +5507,10 @@ func (v Int32Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5323,9 +5525,10 @@ func (v Int32Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValu o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5340,9 +5543,10 @@ func (v Int32Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Int32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5488,14 +5692,16 @@ func (v Int64Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v Int64Value) ToInt(locationRange LocationRange) int { +func (v Int64Value) ToInt(_ LocationRange) int { return int(v) } func (v Int64Value) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { // INT32-C if v == math.MinInt64 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int64 { @@ -5508,9 +5714,13 @@ func (v Int64Value) Negate(interpreter *Interpreter, locationRange LocationRange func safeAddInt64(a, b int64, locationRange LocationRange) int64 { // INT32-C if (b > 0) && (a > (math.MaxInt64 - b)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (b < 0) && (a < (math.MinInt64 - b)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return a + b } @@ -5519,9 +5729,10 @@ func (v Int64Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5536,9 +5747,10 @@ func (v Int64Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5559,17 +5771,22 @@ func (v Int64Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT32-C if (o > 0) && (v < (math.MinInt64 + o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v > (math.MaxInt64 + o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int64 { @@ -5583,9 +5800,10 @@ func (v Int64Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5606,15 +5824,18 @@ func (v Int64Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() int64 { @@ -5628,9 +5849,10 @@ func (v Int64Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5639,24 +5861,32 @@ func (v Int64Value) Mul(interpreter *Interpreter, other NumberValue, locationRan if o > 0 { // positive * positive = positive. overflow? if v > (math.MaxInt64 / o) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } else { // positive * negative = negative. underflow? if o < (math.MinInt64 / v) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } } else { if o > 0 { // negative * positive = negative. underflow? if v < (math.MinInt64 / o) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } } else { // negative * negative = positive. overflow? if (v != 0) && (o < (math.MaxInt64 / v)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } } } @@ -5672,9 +5902,10 @@ func (v Int64Value) SaturatingMul(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5715,18 +5946,23 @@ func (v Int64Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt64) && (o == -1) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int64 { @@ -5740,9 +5976,10 @@ func (v Int64Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5750,7 +5987,9 @@ func (v Int64Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l // INT33-C // https://golang.org/ref/spec#Integer_operators if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } else if (v == math.MinInt64) && (o == -1) { return math.MaxInt64 } @@ -5764,9 +6003,10 @@ func (v Int64Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5777,9 +6017,10 @@ func (v Int64Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5790,9 +6031,10 @@ func (v Int64Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5804,9 +6046,10 @@ func (v Int64Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5836,9 +6079,13 @@ func ConvertInt64(memoryGauge common.MemoryGauge, value Value, locationRange Loc case BigNumberValue: v := value.ToBigInt(memoryGauge) if v.Cmp(sema.Int64TypeMaxInt) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int64TypeMinInt) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v.Int64() @@ -5858,9 +6105,10 @@ func (v Int64Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5875,9 +6123,10 @@ func (v Int64Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5892,9 +6141,10 @@ func (v Int64Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5909,9 +6159,10 @@ func (v Int64Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValu o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -5926,9 +6177,10 @@ func (v Int64Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Int64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6075,7 +6327,9 @@ func (Int128Value) IsImportable(_ *Interpreter) bool { func (v Int128Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -6113,7 +6367,9 @@ func (v Int128Value) Negate(interpreter *Interpreter, locationRange LocationRang // ... // } if v.BigInt.Cmp(sema.Int128TypeMinIntBig) == 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() *big.Int { @@ -6127,9 +6383,10 @@ func (v Int128Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6149,9 +6406,13 @@ func (v Int128Value) Plus(interpreter *Interpreter, other NumberValue, locationR res := new(big.Int) res.Add(v.BigInt, o.BigInt) if res.Cmp(sema.Int128TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -6164,9 +6425,10 @@ func (v Int128Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6201,9 +6463,10 @@ func (v Int128Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6223,9 +6486,13 @@ func (v Int128Value) Minus(interpreter *Interpreter, other NumberValue, location res := new(big.Int) res.Sub(v.BigInt, o.BigInt) if res.Cmp(sema.Int128TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -6238,9 +6505,10 @@ func (v Int128Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6275,9 +6543,10 @@ func (v Int128Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6285,7 +6554,9 @@ func (v Int128Value) Mod(interpreter *Interpreter, other NumberValue, locationRa res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.Rem(v.BigInt, o.BigInt) @@ -6299,9 +6570,10 @@ func (v Int128Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6309,9 +6581,13 @@ func (v Int128Value) Mul(interpreter *Interpreter, other NumberValue, locationRa res := new(big.Int) res.Mul(v.BigInt, o.BigInt) if res.Cmp(sema.Int128TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -6324,9 +6600,10 @@ func (v Int128Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6349,9 +6626,10 @@ func (v Int128Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6364,11 +6642,15 @@ func (v Int128Value) Div(interpreter *Interpreter, other NumberValue, locationRa // ... // } if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.SetInt64(-1) if (v.BigInt.Cmp(sema.Int128TypeMinIntBig) == 0) && (o.BigInt.Cmp(res) == 0) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } res.Div(v.BigInt, o.BigInt) @@ -6382,9 +6664,10 @@ func (v Int128Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6397,7 +6680,9 @@ func (v Int128Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, // ... // } if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.SetInt64(-1) if (v.BigInt.Cmp(sema.Int128TypeMinIntBig) == 0) && (o.BigInt.Cmp(res) == 0) { @@ -6415,9 +6700,10 @@ func (v Int128Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6429,9 +6715,10 @@ func (v Int128Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6443,9 +6730,10 @@ func (v Int128Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6457,9 +6745,10 @@ func (v Int128Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6511,9 +6800,13 @@ func ConvertInt128(memoryGauge common.MemoryGauge, value Value, locationRange Lo } if v.Cmp(sema.Int128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int128TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v @@ -6526,9 +6819,10 @@ func (v Int128Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6545,9 +6839,10 @@ func (v Int128Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6564,9 +6859,10 @@ func (v Int128Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6583,17 +6879,22 @@ func (v Int128Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() *big.Int { @@ -6609,17 +6910,22 @@ func (v Int128Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Int128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() *big.Int { @@ -6765,7 +7071,9 @@ func (Int256Value) IsImportable(_ *Interpreter) bool { func (v Int256Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -6803,7 +7111,9 @@ func (v Int256Value) Negate(interpreter *Interpreter, locationRange LocationRang // ... // } if v.BigInt.Cmp(sema.Int256TypeMinIntBig) == 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() *big.Int { @@ -6817,9 +7127,10 @@ func (v Int256Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6839,9 +7150,13 @@ func (v Int256Value) Plus(interpreter *Interpreter, other NumberValue, locationR res := new(big.Int) res.Add(v.BigInt, o.BigInt) if res.Cmp(sema.Int256TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -6854,9 +7169,10 @@ func (v Int256Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6891,9 +7207,10 @@ func (v Int256Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6913,9 +7230,13 @@ func (v Int256Value) Minus(interpreter *Interpreter, other NumberValue, location res := new(big.Int) res.Sub(v.BigInt, o.BigInt) if res.Cmp(sema.Int256TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -6928,9 +7249,10 @@ func (v Int256Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6965,9 +7287,10 @@ func (v Int256Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6975,7 +7298,9 @@ func (v Int256Value) Mod(interpreter *Interpreter, other NumberValue, locationRa res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.Rem(v.BigInt, o.BigInt) @@ -6989,9 +7314,10 @@ func (v Int256Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -6999,9 +7325,13 @@ func (v Int256Value) Mul(interpreter *Interpreter, other NumberValue, locationRa res := new(big.Int) res.Mul(v.BigInt, o.BigInt) if res.Cmp(sema.Int256TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if res.Cmp(sema.Int256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res @@ -7014,9 +7344,10 @@ func (v Int256Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7039,9 +7370,10 @@ func (v Int256Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7054,11 +7386,15 @@ func (v Int256Value) Div(interpreter *Interpreter, other NumberValue, locationRa // ... // } if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.SetInt64(-1) if (v.BigInt.Cmp(sema.Int256TypeMinIntBig) == 0) && (o.BigInt.Cmp(res) == 0) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } res.Div(v.BigInt, o.BigInt) return res @@ -7071,9 +7407,10 @@ func (v Int256Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7086,7 +7423,9 @@ func (v Int256Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, // ... // } if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.SetInt64(-1) if (v.BigInt.Cmp(sema.Int256TypeMinIntBig) == 0) && (o.BigInt.Cmp(res) == 0) { @@ -7103,9 +7442,10 @@ func (v Int256Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7117,9 +7457,10 @@ func (v Int256Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7131,9 +7472,10 @@ func (v Int256Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7145,9 +7487,10 @@ func (v Int256Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7199,9 +7542,13 @@ func ConvertInt256(memoryGauge common.MemoryGauge, value Value, locationRange Lo } if v.Cmp(sema.Int256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Cmp(sema.Int256TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v @@ -7214,9 +7561,10 @@ func (v Int256Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7233,9 +7581,10 @@ func (v Int256Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7252,9 +7601,10 @@ func (v Int256Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7271,19 +7621,24 @@ func (v Int256Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } valueGetter := func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } res.Lsh(v.BigInt, uint(o.BigInt.Uint64())) @@ -7297,19 +7652,24 @@ func (v Int256Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Int256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } valueGetter := func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } res.Rsh(v.BigInt, uint(o.BigInt.Uint64())) return res @@ -7439,7 +7799,9 @@ func ConvertUInt(memoryGauge common.MemoryGauge, value Value, locationRange Loca func() *big.Int { v := value.ToBigInt(memoryGauge) if v.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v }, @@ -7448,7 +7810,9 @@ func ConvertUInt(memoryGauge common.MemoryGauge, value Value, locationRange Loca case NumberValue: v := value.ToInt(locationRange) if v < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return NewUIntValueFromUint64( memoryGauge, @@ -7489,7 +7853,9 @@ func (v UIntValue) IsImportable(_ *Interpreter) bool { func (v UIntValue) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -7529,9 +7895,10 @@ func (v UIntValue) Plus(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7550,9 +7917,10 @@ func (v UIntValue) SaturatingPlus(interpreter *Interpreter, other NumberValue, l r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -7564,9 +7932,10 @@ func (v UIntValue) Minus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7578,7 +7947,9 @@ func (v UIntValue) Minus(interpreter *Interpreter, other NumberValue, locationRa res.Sub(v.BigInt, o.BigInt) // INT30-C if res.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return res }, @@ -7589,9 +7960,10 @@ func (v UIntValue) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7614,9 +7986,10 @@ func (v UIntValue) Mod(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7627,7 +8000,9 @@ func (v UIntValue) Mod(interpreter *Interpreter, other NumberValue, locationRang res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } res.Rem(v.BigInt, o.BigInt) return res @@ -7639,9 +8014,10 @@ func (v UIntValue) Mul(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7660,9 +8036,10 @@ func (v UIntValue) SaturatingMul(interpreter *Interpreter, other NumberValue, lo r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -7674,9 +8051,10 @@ func (v UIntValue) Div(interpreter *Interpreter, other NumberValue, locationRang o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7687,7 +8065,9 @@ func (v UIntValue) Div(interpreter *Interpreter, other NumberValue, locationRang res := new(big.Int) // INT33-C if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -7699,9 +8079,10 @@ func (v UIntValue) SaturatingDiv(interpreter *Interpreter, other NumberValue, lo r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -7713,9 +8094,10 @@ func (v UIntValue) Less(interpreter *Interpreter, other ComparableValue, locatio o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7727,9 +8109,10 @@ func (v UIntValue) LessEqual(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7741,9 +8124,10 @@ func (v UIntValue) Greater(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7755,9 +8139,10 @@ func (v UIntValue) GreaterEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7797,9 +8182,10 @@ func (v UIntValue) BitwiseOr(interpreter *Interpreter, other IntegerValue, locat o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7817,9 +8203,10 @@ func (v UIntValue) BitwiseXor(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7837,9 +8224,10 @@ func (v UIntValue) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -7857,18 +8245,23 @@ func (v UIntValue) BitwiseLeftShift(interpreter *Interpreter, other IntegerValue o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewUIntValueFromBigInt( @@ -7886,17 +8279,22 @@ func (v UIntValue) BitwiseRightShift(interpreter *Interpreter, other IntegerValu o, ok := other.(UIntValue) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewUIntValueFromBigInt( @@ -8042,7 +8440,7 @@ func (v UInt8Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v UInt8Value) ToInt(locationRange LocationRange) int { +func (v UInt8Value) ToInt(_ LocationRange) int { return int(v) } @@ -8054,9 +8452,10 @@ func (v UInt8Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8064,7 +8463,9 @@ func (v UInt8Value) Plus(interpreter *Interpreter, other NumberValue, locationRa sum := v + o // INT30-C if sum < v { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint8(sum) }) @@ -8074,9 +8475,10 @@ func (v UInt8Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8094,9 +8496,10 @@ func (v UInt8Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8106,7 +8509,9 @@ func (v UInt8Value) Minus(interpreter *Interpreter, other NumberValue, locationR diff := v - o // INT30-C if diff > v { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint8(diff) }, @@ -8117,9 +8522,10 @@ func (v UInt8Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8140,9 +8546,10 @@ func (v UInt8Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8150,7 +8557,9 @@ func (v UInt8Value) Mod(interpreter *Interpreter, other NumberValue, locationRan interpreter, func() uint8 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint8(v % o) }, @@ -8161,9 +8570,10 @@ func (v UInt8Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8172,7 +8582,9 @@ func (v UInt8Value) Mul(interpreter *Interpreter, other NumberValue, locationRan func() uint8 { // INT30-C if (v > 0) && (o > 0) && (v > (math.MaxUint8 / o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint8(v * o) }, @@ -8183,9 +8595,10 @@ func (v UInt8Value) SaturatingMul(interpreter *Interpreter, other NumberValue, l o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8205,9 +8618,10 @@ func (v UInt8Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8215,7 +8629,9 @@ func (v UInt8Value) Div(interpreter *Interpreter, other NumberValue, locationRan interpreter, func() uint8 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint8(v / o) }, @@ -8227,9 +8643,10 @@ func (v UInt8Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -8241,9 +8658,10 @@ func (v UInt8Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8254,9 +8672,10 @@ func (v UInt8Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8267,9 +8686,10 @@ func (v UInt8Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8280,9 +8700,10 @@ func (v UInt8Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8317,18 +8738,26 @@ func ConvertUnsigned[T Unsigned]( case BigNumberValue: v := value.ToBigInt(memoryGauge) if v.Cmp(maxBigNumber) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return T(v.Int64()) case NumberValue: v := value.ToInt(locationRange) if maxNumber > 0 && v > maxNumber { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return T(v) @@ -8373,9 +8802,10 @@ func (v UInt8Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8391,9 +8821,10 @@ func (v UInt8Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8409,9 +8840,10 @@ func (v UInt8Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8427,9 +8859,10 @@ func (v UInt8Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValu o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8445,9 +8878,10 @@ func (v UInt8Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVal o, ok := other.(UInt8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8592,7 +9026,7 @@ func (v UInt16Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen return v.String() } -func (v UInt16Value) ToInt(locationRange LocationRange) int { +func (v UInt16Value) ToInt(_ LocationRange) int { return int(v) } func (v UInt16Value) Negate(*Interpreter, LocationRange) NumberValue { @@ -8603,9 +9037,10 @@ func (v UInt16Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8615,7 +9050,9 @@ func (v UInt16Value) Plus(interpreter *Interpreter, other NumberValue, locationR sum := v + o // INT30-C if sum < v { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint16(sum) }, @@ -8626,9 +9063,10 @@ func (v UInt16Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8649,9 +9087,10 @@ func (v UInt16Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8661,7 +9100,9 @@ func (v UInt16Value) Minus(interpreter *Interpreter, other NumberValue, location diff := v - o // INT30-C if diff > v { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint16(diff) }, @@ -8672,9 +9113,10 @@ func (v UInt16Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8695,9 +9137,10 @@ func (v UInt16Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8705,7 +9148,9 @@ func (v UInt16Value) Mod(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint16 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint16(v % o) }, @@ -8716,9 +9161,10 @@ func (v UInt16Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8727,7 +9173,9 @@ func (v UInt16Value) Mul(interpreter *Interpreter, other NumberValue, locationRa func() uint16 { // INT30-C if (v > 0) && (o > 0) && (v > (math.MaxUint16 / o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint16(v * o) }, @@ -8738,9 +9186,10 @@ func (v UInt16Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8760,9 +9209,10 @@ func (v UInt16Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8770,7 +9220,9 @@ func (v UInt16Value) Div(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint16 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint16(v / o) }, @@ -8782,9 +9234,10 @@ func (v UInt16Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -8796,9 +9249,10 @@ func (v UInt16Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8809,9 +9263,10 @@ func (v UInt16Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8822,9 +9277,10 @@ func (v UInt16Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8835,9 +9291,10 @@ func (v UInt16Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8880,9 +9337,10 @@ func (v UInt16Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8898,9 +9356,10 @@ func (v UInt16Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8916,9 +9375,10 @@ func (v UInt16Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8934,9 +9394,10 @@ func (v UInt16Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -8952,9 +9413,10 @@ func (v UInt16Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(UInt16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9105,7 +9567,7 @@ func (v UInt32Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen return v.String() } -func (v UInt32Value) ToInt(locationRange LocationRange) int { +func (v UInt32Value) ToInt(_ LocationRange) int { return int(v) } @@ -9117,9 +9579,10 @@ func (v UInt32Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9129,7 +9592,9 @@ func (v UInt32Value) Plus(interpreter *Interpreter, other NumberValue, locationR sum := v + o // INT30-C if sum < v { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint32(sum) }, @@ -9140,9 +9605,10 @@ func (v UInt32Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9163,9 +9629,10 @@ func (v UInt32Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9175,7 +9642,9 @@ func (v UInt32Value) Minus(interpreter *Interpreter, other NumberValue, location diff := v - o // INT30-C if diff > v { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint32(diff) }, @@ -9186,9 +9655,10 @@ func (v UInt32Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9209,9 +9679,10 @@ func (v UInt32Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9219,7 +9690,9 @@ func (v UInt32Value) Mod(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint32 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint32(v % o) }, @@ -9230,9 +9703,10 @@ func (v UInt32Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9240,7 +9714,9 @@ func (v UInt32Value) Mul(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint32 { if (v > 0) && (o > 0) && (v > (math.MaxUint32 / o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint32(v * o) }, @@ -9251,9 +9727,10 @@ func (v UInt32Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9274,9 +9751,10 @@ func (v UInt32Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9284,7 +9762,9 @@ func (v UInt32Value) Div(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint32 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint32(v / o) }, @@ -9296,9 +9776,10 @@ func (v UInt32Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -9310,9 +9791,10 @@ func (v UInt32Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9323,9 +9805,10 @@ func (v UInt32Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9336,9 +9819,10 @@ func (v UInt32Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9349,9 +9833,10 @@ func (v UInt32Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9394,9 +9879,10 @@ func (v UInt32Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9412,9 +9898,10 @@ func (v UInt32Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9430,9 +9917,10 @@ func (v UInt32Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9448,9 +9936,10 @@ func (v UInt32Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9466,9 +9955,10 @@ func (v UInt32Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(UInt32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9627,7 +10117,9 @@ func (v UInt64Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen func (v UInt64Value) ToInt(locationRange LocationRange) int { if v > math.MaxInt64 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v) } @@ -9655,7 +10147,9 @@ func safeAddUint64(a, b uint64, locationRange LocationRange) uint64 { sum := a + b // INT30-C if sum < a { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return sum } @@ -9664,9 +10158,10 @@ func (v UInt64Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9682,9 +10177,10 @@ func (v UInt64Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9705,9 +10201,10 @@ func (v UInt64Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9717,7 +10214,9 @@ func (v UInt64Value) Minus(interpreter *Interpreter, other NumberValue, location diff := v - o // INT30-C if diff > v { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint64(diff) }, @@ -9728,9 +10227,10 @@ func (v UInt64Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9751,9 +10251,10 @@ func (v UInt64Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9761,7 +10262,9 @@ func (v UInt64Value) Mod(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint64 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint64(v % o) }, @@ -9772,9 +10275,10 @@ func (v UInt64Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9782,7 +10286,9 @@ func (v UInt64Value) Mul(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint64 { if (v > 0) && (o > 0) && (v > (math.MaxUint64 / o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return uint64(v * o) }, @@ -9793,9 +10299,10 @@ func (v UInt64Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9815,9 +10322,10 @@ func (v UInt64Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9825,7 +10333,9 @@ func (v UInt64Value) Div(interpreter *Interpreter, other NumberValue, locationRa interpreter, func() uint64 { if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return uint64(v / o) }, @@ -9837,9 +10347,10 @@ func (v UInt64Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -9851,9 +10362,10 @@ func (v UInt64Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9864,9 +10376,10 @@ func (v UInt64Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9877,9 +10390,10 @@ func (v UInt64Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9890,9 +10404,10 @@ func (v UInt64Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9935,9 +10450,10 @@ func (v UInt64Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9953,9 +10469,10 @@ func (v UInt64Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9971,9 +10488,10 @@ func (v UInt64Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -9989,9 +10507,10 @@ func (v UInt64Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10007,9 +10526,10 @@ func (v UInt64Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(UInt64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10161,7 +10681,9 @@ func (UInt128Value) IsImportable(_ *Interpreter) bool { func (v UInt128Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -10201,9 +10723,10 @@ func (v UInt128Value) Plus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10223,7 +10746,9 @@ func (v UInt128Value) Plus(interpreter *Interpreter, other NumberValue, location // } // if sum.Cmp(sema.UInt128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return sum }, @@ -10234,9 +10759,10 @@ func (v UInt128Value) SaturatingPlus(interpreter *Interpreter, other NumberValue o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10267,9 +10793,10 @@ func (v UInt128Value) Minus(interpreter *Interpreter, other NumberValue, locatio o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10289,7 +10816,9 @@ func (v UInt128Value) Minus(interpreter *Interpreter, other NumberValue, locatio // } // if diff.Cmp(sema.UInt128TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return diff }, @@ -10300,9 +10829,10 @@ func (v UInt128Value) SaturatingMinus(interpreter *Interpreter, other NumberValu o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10333,9 +10863,10 @@ func (v UInt128Value) Mod(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10344,7 +10875,9 @@ func (v UInt128Value) Mod(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Rem(v.BigInt, o.BigInt) }, @@ -10355,9 +10888,10 @@ func (v UInt128Value) Mul(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10367,7 +10901,9 @@ func (v UInt128Value) Mul(interpreter *Interpreter, other NumberValue, locationR res := new(big.Int) res.Mul(v.BigInt, o.BigInt) if res.Cmp(sema.UInt128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res }, @@ -10378,9 +10914,10 @@ func (v UInt128Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10401,9 +10938,10 @@ func (v UInt128Value) Div(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10412,7 +10950,9 @@ func (v UInt128Value) Div(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -10425,9 +10965,10 @@ func (v UInt128Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -10439,9 +10980,10 @@ func (v UInt128Value) Less(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10453,9 +10995,10 @@ func (v UInt128Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10467,9 +11010,10 @@ func (v UInt128Value) Greater(interpreter *Interpreter, other ComparableValue, l o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10481,9 +11025,10 @@ func (v UInt128Value) GreaterEqual(interpreter *Interpreter, other ComparableVal o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10538,9 +11083,13 @@ func ConvertUInt128(memoryGauge common.MemoryGauge, value Value, locationRange L } if v.Cmp(sema.UInt128TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v @@ -10552,9 +11101,10 @@ func (v UInt128Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10571,9 +11121,10 @@ func (v UInt128Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, l o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10590,9 +11141,10 @@ func (v UInt128Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, l o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10610,9 +11162,10 @@ func (v UInt128Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10621,10 +11174,14 @@ func (v UInt128Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Lsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -10635,9 +11192,10 @@ func (v UInt128Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV o, ok := other.(UInt128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10646,10 +11204,14 @@ func (v UInt128Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Rsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -10794,7 +11356,9 @@ func (UInt256Value) IsImportable(_ *Interpreter) bool { func (v UInt256Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) @@ -10835,9 +11399,10 @@ func (v UInt256Value) Plus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10857,7 +11422,9 @@ func (v UInt256Value) Plus(interpreter *Interpreter, other NumberValue, location // } // if sum.Cmp(sema.UInt256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return sum }, @@ -10869,9 +11436,10 @@ func (v UInt256Value) SaturatingPlus(interpreter *Interpreter, other NumberValue o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10902,9 +11470,10 @@ func (v UInt256Value) Minus(interpreter *Interpreter, other NumberValue, locatio o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10924,7 +11493,9 @@ func (v UInt256Value) Minus(interpreter *Interpreter, other NumberValue, locatio // } // if diff.Cmp(sema.UInt256TypeMinIntBig) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return diff }, @@ -10935,9 +11506,10 @@ func (v UInt256Value) SaturatingMinus(interpreter *Interpreter, other NumberValu o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10969,9 +11541,10 @@ func (v UInt256Value) Mod(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -10980,7 +11553,9 @@ func (v UInt256Value) Mod(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Rem(v.BigInt, o.BigInt) }, @@ -10991,9 +11566,10 @@ func (v UInt256Value) Mul(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11003,7 +11579,9 @@ func (v UInt256Value) Mul(interpreter *Interpreter, other NumberValue, locationR res := new(big.Int) res.Mul(v.BigInt, o.BigInt) if res.Cmp(sema.UInt256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res }, @@ -11014,9 +11592,10 @@ func (v UInt256Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11037,9 +11616,10 @@ func (v UInt256Value) Div(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11048,7 +11628,9 @@ func (v UInt256Value) Div(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -11060,9 +11642,10 @@ func (v UInt256Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -11074,9 +11657,10 @@ func (v UInt256Value) Less(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11088,9 +11672,10 @@ func (v UInt256Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11102,9 +11687,10 @@ func (v UInt256Value) Greater(interpreter *Interpreter, other ComparableValue, l o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11116,9 +11702,10 @@ func (v UInt256Value) GreaterEqual(interpreter *Interpreter, other ComparableVal o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11172,9 +11759,13 @@ func ConvertUInt256(memoryGauge common.MemoryGauge, value Value, locationRange L } if v.Cmp(sema.UInt256TypeMaxIntBig) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if v.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return v @@ -11186,9 +11777,10 @@ func (v UInt256Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11205,9 +11797,10 @@ func (v UInt256Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, l o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11224,9 +11817,10 @@ func (v UInt256Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, l o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11243,9 +11837,10 @@ func (v UInt256Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11254,10 +11849,14 @@ func (v UInt256Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Lsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -11268,9 +11867,10 @@ func (v UInt256Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV o, ok := other.(UInt256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11279,10 +11879,14 @@ func (v UInt256Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Rsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -11427,7 +12031,7 @@ func (v Word8Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v Word8Value) ToInt(locationRange LocationRange) int { +func (v Word8Value) ToInt(_ LocationRange) int { return int(v) } @@ -11439,9 +12043,10 @@ func (v Word8Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11460,9 +12065,10 @@ func (v Word8Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11481,14 +12087,17 @@ func (v Word8Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint8 { @@ -11502,9 +12111,10 @@ func (v Word8Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11523,14 +12133,17 @@ func (v Word8Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint8 { @@ -11548,9 +12161,10 @@ func (v Word8Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11561,9 +12175,10 @@ func (v Word8Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11574,9 +12189,10 @@ func (v Word8Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11587,9 +12203,10 @@ func (v Word8Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11626,9 +12243,10 @@ func (v Word8Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loca o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11643,9 +12261,10 @@ func (v Word8Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11660,9 +12279,10 @@ func (v Word8Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11677,9 +12297,10 @@ func (v Word8Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerValu o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11694,9 +12315,10 @@ func (v Word8Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Word8Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11846,7 +12468,7 @@ func (v Word16Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen return v.String() } -func (v Word16Value) ToInt(locationRange LocationRange) int { +func (v Word16Value) ToInt(_ LocationRange) int { return int(v) } func (v Word16Value) Negate(*Interpreter, LocationRange) NumberValue { @@ -11857,9 +12479,10 @@ func (v Word16Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11878,9 +12501,10 @@ func (v Word16Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11899,14 +12523,17 @@ func (v Word16Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint16 { @@ -11920,9 +12547,10 @@ func (v Word16Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11941,14 +12569,17 @@ func (v Word16Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint16 { @@ -11966,9 +12597,10 @@ func (v Word16Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11979,9 +12611,10 @@ func (v Word16Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -11992,9 +12625,10 @@ func (v Word16Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12005,9 +12639,10 @@ func (v Word16Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12044,9 +12679,10 @@ func (v Word16Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12061,9 +12697,10 @@ func (v Word16Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12078,9 +12715,10 @@ func (v Word16Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12095,9 +12733,10 @@ func (v Word16Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12112,9 +12751,10 @@ func (v Word16Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Word16Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12266,7 +12906,7 @@ func (v Word32Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen return v.String() } -func (v Word32Value) ToInt(locationRange LocationRange) int { +func (v Word32Value) ToInt(_ LocationRange) int { return int(v) } @@ -12278,9 +12918,10 @@ func (v Word32Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12299,9 +12940,10 @@ func (v Word32Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12320,14 +12962,17 @@ func (v Word32Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint32 { @@ -12341,9 +12986,10 @@ func (v Word32Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12362,14 +13008,17 @@ func (v Word32Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint32 { @@ -12387,9 +13036,10 @@ func (v Word32Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12400,9 +13050,10 @@ func (v Word32Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12413,9 +13064,10 @@ func (v Word32Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12426,9 +13078,10 @@ func (v Word32Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12465,9 +13118,10 @@ func (v Word32Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12482,9 +13136,10 @@ func (v Word32Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12499,9 +13154,10 @@ func (v Word32Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12516,9 +13172,10 @@ func (v Word32Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12533,9 +13190,10 @@ func (v Word32Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Word32Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12695,7 +13353,9 @@ func (v Word64Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen func (v Word64Value) ToInt(locationRange LocationRange) int { if v > math.MaxInt64 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v) } @@ -12723,9 +13383,10 @@ func (v Word64Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12744,9 +13405,10 @@ func (v Word64Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12765,14 +13427,17 @@ func (v Word64Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint64 { @@ -12786,9 +13451,10 @@ func (v Word64Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12807,14 +13473,17 @@ func (v Word64Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } if o == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } valueGetter := func() uint64 { @@ -12832,9 +13501,10 @@ func (v Word64Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12845,9 +13515,10 @@ func (v Word64Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12858,9 +13529,10 @@ func (v Word64Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12871,9 +13543,10 @@ func (v Word64Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12910,9 +13583,10 @@ func (v Word64Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, loc o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12927,9 +13601,10 @@ func (v Word64Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12944,9 +13619,10 @@ func (v Word64Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12961,9 +13637,10 @@ func (v Word64Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVal o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -12978,9 +13655,10 @@ func (v Word64Value) BitwiseRightShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Word64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13131,7 +13809,9 @@ func (Word128Value) IsImportable(_ *Interpreter) bool { func (v Word128Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -13171,9 +13851,10 @@ func (v Word128Value) Plus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13204,7 +13885,7 @@ func (v Word128Value) Plus(interpreter *Interpreter, other NumberValue, location ) } -func (v Word128Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word128Value) SaturatingPlus(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13212,9 +13893,10 @@ func (v Word128Value) Minus(interpreter *Interpreter, other NumberValue, locatio o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13245,7 +13927,7 @@ func (v Word128Value) Minus(interpreter *Interpreter, other NumberValue, locatio ) } -func (v Word128Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word128Value) SaturatingMinus(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13253,9 +13935,10 @@ func (v Word128Value) Mod(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13264,7 +13947,9 @@ func (v Word128Value) Mod(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Rem(v.BigInt, o.BigInt) }, @@ -13275,9 +13960,10 @@ func (v Word128Value) Mul(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13294,7 +13980,7 @@ func (v Word128Value) Mul(interpreter *Interpreter, other NumberValue, locationR ) } -func (v Word128Value) SaturatingMul(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word128Value) SaturatingMul(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13302,9 +13988,10 @@ func (v Word128Value) Div(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13313,7 +14000,9 @@ func (v Word128Value) Div(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -13321,7 +14010,7 @@ func (v Word128Value) Div(interpreter *Interpreter, other NumberValue, locationR } -func (v Word128Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word128Value) SaturatingDiv(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13329,9 +14018,10 @@ func (v Word128Value) Less(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13343,9 +14033,10 @@ func (v Word128Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13357,9 +14048,10 @@ func (v Word128Value) Greater(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13371,9 +14063,10 @@ func (v Word128Value) GreaterEqual(interpreter *Interpreter, other ComparableVal o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13442,9 +14135,10 @@ func (v Word128Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13461,9 +14155,10 @@ func (v Word128Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, l o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13480,9 +14175,10 @@ func (v Word128Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, l o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13500,9 +14196,10 @@ func (v Word128Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Word128Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13511,10 +14208,14 @@ func (v Word128Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Lsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -13536,10 +14237,14 @@ func (v Word128Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Rsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -13684,7 +14389,9 @@ func (Word256Value) IsImportable(_ *Interpreter) bool { func (v Word256Value) ToInt(locationRange LocationRange) int { if !v.BigInt.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return int(v.BigInt.Int64()) } @@ -13724,9 +14431,10 @@ func (v Word256Value) Plus(interpreter *Interpreter, other NumberValue, location o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13757,7 +14465,7 @@ func (v Word256Value) Plus(interpreter *Interpreter, other NumberValue, location ) } -func (v Word256Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word256Value) SaturatingPlus(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13765,9 +14473,10 @@ func (v Word256Value) Minus(interpreter *Interpreter, other NumberValue, locatio o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13798,7 +14507,7 @@ func (v Word256Value) Minus(interpreter *Interpreter, other NumberValue, locatio ) } -func (v Word256Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word256Value) SaturatingMinus(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13806,9 +14515,10 @@ func (v Word256Value) Mod(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13817,7 +14527,9 @@ func (v Word256Value) Mod(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Rem(v.BigInt, o.BigInt) }, @@ -13828,9 +14540,10 @@ func (v Word256Value) Mul(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13847,7 +14560,7 @@ func (v Word256Value) Mul(interpreter *Interpreter, other NumberValue, locationR ) } -func (v Word256Value) SaturatingMul(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word256Value) SaturatingMul(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13855,9 +14568,10 @@ func (v Word256Value) Div(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13866,7 +14580,9 @@ func (v Word256Value) Div(interpreter *Interpreter, other NumberValue, locationR func() *big.Int { res := new(big.Int) if o.BigInt.Cmp(res) == 0 { - panic(DivisionByZeroError{LocationRange: locationRange}) + panic(DivisionByZeroError{ + LocationRange: locationRange, + }) } return res.Div(v.BigInt, o.BigInt) }, @@ -13874,7 +14590,7 @@ func (v Word256Value) Div(interpreter *Interpreter, other NumberValue, locationR } -func (v Word256Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, locationRange LocationRange) NumberValue { +func (v Word256Value) SaturatingDiv(_ *Interpreter, _ NumberValue, _ LocationRange) NumberValue { panic(errors.NewUnreachableError()) } @@ -13882,9 +14598,10 @@ func (v Word256Value) Less(interpreter *Interpreter, other ComparableValue, loca o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13896,9 +14613,10 @@ func (v Word256Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13910,9 +14628,10 @@ func (v Word256Value) Greater(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13924,9 +14643,10 @@ func (v Word256Value) GreaterEqual(interpreter *Interpreter, other ComparableVal o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -13995,9 +14715,10 @@ func (v Word256Value) BitwiseOr(interpreter *Interpreter, other IntegerValue, lo o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseOr, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseOr, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14014,9 +14735,10 @@ func (v Word256Value) BitwiseXor(interpreter *Interpreter, other IntegerValue, l o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseXor, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseXor, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14033,9 +14755,10 @@ func (v Word256Value) BitwiseAnd(interpreter *Interpreter, other IntegerValue, l o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseAnd, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseAnd, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14053,9 +14776,10 @@ func (v Word256Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseLeftShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseLeftShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14064,10 +14788,14 @@ func (v Word256Value) BitwiseLeftShift(interpreter *Interpreter, other IntegerVa func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Lsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -14078,9 +14806,10 @@ func (v Word256Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV o, ok := other.(Word256Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationBitwiseRightShift, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationBitwiseRightShift, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14089,10 +14818,14 @@ func (v Word256Value) BitwiseRightShift(interpreter *Interpreter, other IntegerV func() *big.Int { res := new(big.Int) if o.BigInt.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if !o.BigInt.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return res.Rsh(v.BigInt, uint(o.BigInt.Uint64())) }, @@ -14199,11 +14932,15 @@ func NewFix64ValueWithInteger(gauge common.MemoryGauge, constructor func() int64 func NewUnmeteredFix64ValueWithInteger(integer int64, locationRange LocationRange) Fix64Value { if integer < sema.Fix64TypeMinInt { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } if integer > sema.Fix64TypeMaxInt { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewUnmeteredFix64Value(integer * sema.Fix64Factor) @@ -14263,14 +15000,16 @@ func (v Fix64Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferenc return v.String() } -func (v Fix64Value) ToInt(locationRange LocationRange) int { +func (v Fix64Value) ToInt(_ LocationRange) int { return int(v / sema.Fix64Factor) } func (v Fix64Value) Negate(interpreter *Interpreter, locationRange LocationRange) NumberValue { // INT32-C if v == math.MinInt64 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } valueGetter := func() int64 { @@ -14284,9 +15023,10 @@ func (v Fix64Value) Plus(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14301,9 +15041,10 @@ func (v Fix64Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14324,18 +15065,23 @@ func (v Fix64Value) Minus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } valueGetter := func() int64 { // INT32-C if (o > 0) && (v < (math.MinInt64 + o)) { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } else if (o < 0) && (v > (math.MaxInt64 + o)) { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return int64(v - o) @@ -14348,9 +15094,10 @@ func (v Fix64Value) SaturatingMinus(interpreter *Interpreter, other NumberValue, o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14374,9 +15121,10 @@ func (v Fix64Value) Mul(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14388,9 +15136,13 @@ func (v Fix64Value) Mul(interpreter *Interpreter, other NumberValue, locationRan result.Div(result, sema.Fix64FactorBig) if result.Cmp(minInt64Big) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if result.Cmp(maxInt64Big) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return result.Int64() @@ -14403,9 +15155,10 @@ func (v Fix64Value) SaturatingMul(interpreter *Interpreter, other NumberValue, l o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14432,9 +15185,10 @@ func (v Fix64Value) Div(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14446,9 +15200,13 @@ func (v Fix64Value) Div(interpreter *Interpreter, other NumberValue, locationRan result.Div(result, b) if result.Cmp(minInt64Big) < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } else if result.Cmp(maxInt64Big) > 0 { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return result.Int64() @@ -14461,9 +15219,10 @@ func (v Fix64Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, l o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14490,9 +15249,10 @@ func (v Fix64Value) Mod(interpreter *Interpreter, other NumberValue, locationRan o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14500,9 +15260,10 @@ func (v Fix64Value) Mod(interpreter *Interpreter, other NumberValue, locationRan quotient, ok := v.Div(interpreter, o, locationRange).(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14524,9 +15285,10 @@ func (v Fix64Value) Less(interpreter *Interpreter, other ComparableValue, locati o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14537,9 +15299,10 @@ func (v Fix64Value) LessEqual(interpreter *Interpreter, other ComparableValue, l o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14550,9 +15313,10 @@ func (v Fix64Value) Greater(interpreter *Interpreter, other ComparableValue, loc o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14563,9 +15327,10 @@ func (v Fix64Value) GreaterEqual(interpreter *Interpreter, other ComparableValue o, ok := other.(Fix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14596,7 +15361,9 @@ func ConvertFix64(memoryGauge common.MemoryGauge, value Value, locationRange Loc case UFix64Value: if value > Fix64MaxValue { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewFix64Value( memoryGauge, @@ -14614,7 +15381,9 @@ func ConvertFix64(memoryGauge common.MemoryGauge, value Value, locationRange Loc // allows us to call `v.Int64()` safely. if !v.IsInt64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return v.Int64() @@ -14740,7 +15509,9 @@ func NewUFix64ValueWithInteger(gauge common.MemoryGauge, constructor func() uint func NewUnmeteredUFix64ValueWithInteger(integer uint64, locationRange LocationRange) UFix64Value { if integer > sema.UFix64TypeMaxInt { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return NewUnmeteredUFix64Value(integer * sema.Fix64Factor) @@ -14800,7 +15571,7 @@ func (v UFix64Value) MeteredString(memoryGauge common.MemoryGauge, _ SeenReferen return v.String() } -func (v UFix64Value) ToInt(locationRange LocationRange) int { +func (v UFix64Value) ToInt(_ LocationRange) int { return int(v / sema.Fix64Factor) } @@ -14812,9 +15583,10 @@ func (v UFix64Value) Plus(interpreter *Interpreter, other NumberValue, locationR o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationPlus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationPlus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14829,9 +15601,10 @@ func (v UFix64Value) SaturatingPlus(interpreter *Interpreter, other NumberValue, o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingAddFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingAddFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14851,9 +15624,10 @@ func (v UFix64Value) Minus(interpreter *Interpreter, other NumberValue, location o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMinus, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMinus, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14862,7 +15636,9 @@ func (v UFix64Value) Minus(interpreter *Interpreter, other NumberValue, location // INT30-C if diff > v { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint64(diff) } @@ -14874,9 +15650,10 @@ func (v UFix64Value) SaturatingMinus(interpreter *Interpreter, other NumberValue o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingSubtractFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14897,9 +15674,10 @@ func (v UFix64Value) Mul(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMul, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMul, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14911,7 +15689,9 @@ func (v UFix64Value) Mul(interpreter *Interpreter, other NumberValue, locationRa result.Div(result, sema.Fix64FactorBig) if !result.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return result.Uint64() @@ -14924,9 +15704,10 @@ func (v UFix64Value) SaturatingMul(interpreter *Interpreter, other NumberValue, o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingMultiplyFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14951,9 +15732,10 @@ func (v UFix64Value) Div(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationDiv, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationDiv, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14975,9 +15757,10 @@ func (v UFix64Value) SaturatingDiv(interpreter *Interpreter, other NumberValue, r := recover() if _, ok := r.(InvalidOperandsError); ok { panic(InvalidOperandsError{ - FunctionName: sema.NumericTypeSaturatingDivideFunctionName, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + FunctionName: sema.NumericTypeSaturatingDivideFunctionName, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } }() @@ -14989,9 +15772,10 @@ func (v UFix64Value) Mod(interpreter *Interpreter, other NumberValue, locationRa o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -14999,9 +15783,10 @@ func (v UFix64Value) Mod(interpreter *Interpreter, other NumberValue, locationRa quotient, ok := v.Div(interpreter, o, locationRange).(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationMod, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationMod, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -15023,9 +15808,10 @@ func (v UFix64Value) Less(interpreter *Interpreter, other ComparableValue, locat o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLess, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLess, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -15036,9 +15822,10 @@ func (v UFix64Value) LessEqual(interpreter *Interpreter, other ComparableValue, o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationLessEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationLessEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -15049,9 +15836,10 @@ func (v UFix64Value) Greater(interpreter *Interpreter, other ComparableValue, lo o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreater, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreater, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -15062,9 +15850,10 @@ func (v UFix64Value) GreaterEqual(interpreter *Interpreter, other ComparableValu o, ok := other.(UFix64Value) if !ok { panic(InvalidOperandsError{ - Operation: ast.OperationGreaterEqual, - LeftType: v.StaticType(interpreter), - RightType: other.StaticType(interpreter), + Operation: ast.OperationGreaterEqual, + LeftType: v.StaticType(interpreter), + RightType: other.StaticType(interpreter), + LocationRange: locationRange, }) } @@ -15095,7 +15884,9 @@ func ConvertUFix64(memoryGauge common.MemoryGauge, value Value, locationRange Lo case Fix64Value: if value < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return NewUFix64Value( memoryGauge, @@ -15109,7 +15900,9 @@ func ConvertUFix64(memoryGauge common.MemoryGauge, value Value, locationRange Lo v := value.ToBigInt(memoryGauge) if v.Sign() < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } // First, check if the value is at least in the uint64 range. @@ -15117,7 +15910,9 @@ func ConvertUFix64(memoryGauge common.MemoryGauge, value Value, locationRange Lo // allows us to call `v.UInt64()` safely. if !v.IsUint64() { - panic(OverflowError{LocationRange: locationRange}) + panic(OverflowError{ + LocationRange: locationRange, + }) } return v.Uint64() @@ -15130,7 +15925,9 @@ func ConvertUFix64(memoryGauge common.MemoryGauge, value Value, locationRange Lo converter := func() uint64 { v := value.ToInt(locationRange) if v < 0 { - panic(UnderflowError{LocationRange: locationRange}) + panic(UnderflowError{ + LocationRange: locationRange, + }) } return uint64(v) @@ -15493,7 +16290,7 @@ func (v *CompositeValue) Destroy(interpreter *Interpreter, locationRange Locatio var base *EphemeralReferenceValue var self MemberAccessibleValue = v if v.Kind == common.CompositeKindAttachment { - base, self = attachmentBaseAndSelfValues(interpreter, locationRange, v) + base, self = attachmentBaseAndSelfValues(interpreter, v) } invocation := NewInvocation( interpreter, @@ -15633,7 +16430,7 @@ func (v *CompositeValue) GetMember(interpreter *Interpreter, locationRange Locat var base *EphemeralReferenceValue var self MemberAccessibleValue = v if v.Kind == common.CompositeKindAttachment { - base, self = attachmentBaseAndSelfValues(interpreter, locationRange, v) + base, self = attachmentBaseAndSelfValues(interpreter, v) } return NewBoundFunctionValue(interpreter, function, &self, base) } @@ -16041,7 +16838,7 @@ func (v *CompositeValue) ConformsToStaticType( } if compositeType.Kind == common.CompositeKindAttachment { - base := v.getBaseValue(interpreter, locationRange).Value + base := v.getBaseValue().Value if base == nil || !base.ConformsToStaticType(interpreter, locationRange, results) { return false } @@ -16547,7 +17344,7 @@ func NewEnumCaseValue( return v } -func (v *CompositeValue) getBaseValue(interpreter *Interpreter, locationRange LocationRange) *EphemeralReferenceValue { +func (v *CompositeValue) getBaseValue() *EphemeralReferenceValue { return v.base } @@ -16592,10 +17389,9 @@ func (v *CompositeValue) GetAttachments(interpreter *Interpreter, locationRange func attachmentBaseAndSelfValues( interpreter *Interpreter, - locationRange LocationRange, v *CompositeValue, ) (base *EphemeralReferenceValue, self *EphemeralReferenceValue) { - base = v.getBaseValue(interpreter, locationRange) + base = v.getBaseValue() // in attachment functions, self is a reference value self = NewEphemeralReferenceValue(interpreter, false, v, interpreter.MustSemaTypeOfValue(v)) interpreter.trackReferencedResourceKindedValue(v.StorageID(), v) @@ -18959,8 +19755,8 @@ func (*EphemeralReferenceValue) IsImportable(_ *Interpreter) bool { } func (v *EphemeralReferenceValue) ReferencedValue( - interpreter *Interpreter, - locationRange LocationRange, + _ *Interpreter, + _ LocationRange, _ bool, ) *Value { return &v.Value diff --git a/runtime/literal.go b/runtime/literal.go index 521db21801..6b7d42ef37 100644 --- a/runtime/literal.go +++ b/runtime/literal.go @@ -97,7 +97,8 @@ func ParseLiteralArgumentList( parameterType := parameterTypes[i] value, err := LiteralValue(inter, argument.Expression, parameterType) if err != nil { - return nil, parser.NewUnpositionedSyntaxError( + return nil, parser.NewSyntaxError( + argument.Expression.StartPosition(), "invalid argument at index %d: %v", i, err, ) } diff --git a/runtime/parser/errors.go b/runtime/parser/errors.go index e870aacbd4..5e2381e8d2 100644 --- a/runtime/parser/errors.go +++ b/runtime/parser/errors.go @@ -74,6 +74,7 @@ func NewSyntaxError(pos ast.Position, message string, params ...any) *SyntaxErro func NewUnpositionedSyntaxError(message string, params ...any) *SyntaxError { return &SyntaxError{ + Pos: ast.Position{Line: 1}, Message: fmt.Sprintf(message, params...), } } From 937ff73e5a88a53df49874644ede7263e7e0ddfb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 2 Aug 2023 17:08:44 -0700 Subject: [PATCH 3/4] ensure errors with location, position, and suggested fixes, can produce them --- runtime/tests/utils/utils.go | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/runtime/tests/utils/utils.go b/runtime/tests/utils/utils.go index c630385a63..8835a83c6b 100644 --- a/runtime/tests/utils/utils.go +++ b/runtime/tests/utils/utils.go @@ -28,8 +28,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/onflow/cadence/runtime/ast" "github.com/onflow/cadence/runtime/errors" "github.com/onflow/cadence/runtime/interpreter" + "github.com/onflow/cadence/runtime/sema" "github.com/onflow/cadence/runtime/common" ) @@ -207,6 +209,16 @@ func RequireError(t *testing.T, err error) { _ = err.Error() + if hasImportLocation, ok := err.(common.HasLocation); ok { + location := hasImportLocation.ImportLocation() + assert.NotNil(t, location) + } + + if hasPosition, ok := err.(ast.HasPosition); ok { + _ = hasPosition.StartPosition() + _ = hasPosition.EndPosition(nil) + } + if hasErrorNotes, ok := err.(errors.ErrorNotes); ok { for _, note := range hasErrorNotes.ErrorNotes() { _ = note.Message() @@ -216,4 +228,8 @@ func RequireError(t *testing.T, err error) { if hasSecondaryError, ok := err.(errors.SecondaryError); ok { _ = hasSecondaryError.SecondaryError() } + + if hasSuggestedFixes, ok := err.(sema.HasSuggestedFixes); ok { + _ = hasSuggestedFixes.SuggestFixes("") + } } From d278372235ca974ecff6bb2c7cf2b50fcadf09f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bastian=20M=C3=BCller?= Date: Wed, 2 Aug 2023 17:08:57 -0700 Subject: [PATCH 4/4] fix error types --- runtime/parser/expression.go | 6 +++--- runtime/parser/type.go | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/runtime/parser/expression.go b/runtime/parser/expression.go index a6378b77bc..81620434a0 100644 --- a/runtime/parser/expression.go +++ b/runtime/parser/expression.go @@ -198,7 +198,7 @@ func defineExpr(def any) { func setExprNullDenotation(tokenType lexer.TokenType, nullDenotation exprNullDenotationFunc) { current := exprNullDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "expression null denotation for token %s already exists", tokenType, )) @@ -225,7 +225,7 @@ func setExprIdentifierLeftBindingPower(keyword string, power int) { func setExprLeftDenotation(tokenType lexer.TokenType, leftDenotation exprLeftDenotationFunc) { current := exprLeftDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "expression left denotation for token %s already exists", tokenType, )) @@ -237,7 +237,7 @@ func setExprLeftDenotation(tokenType lexer.TokenType, leftDenotation exprLeftDen func setExprMetaLeftDenotation(tokenType lexer.TokenType, metaLeftDenotation exprMetaLeftDenotationFunc) { current := exprMetaLeftDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "expression meta left denotation for token %s already exists", tokenType, )) diff --git a/runtime/parser/type.go b/runtime/parser/type.go index 1c862419a8..80b764b98f 100644 --- a/runtime/parser/type.go +++ b/runtime/parser/type.go @@ -53,7 +53,7 @@ var typeMetaLeftDenotations [lexer.TokenMax]typeMetaLeftDenotationFunc func setTypeNullDenotation(tokenType lexer.TokenType, nullDenotation typeNullDenotationFunc) { current := typeNullDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "type null denotation for token %s already exists", tokenType, )) @@ -72,7 +72,7 @@ func setTypeLeftBindingPower(tokenType lexer.TokenType, power int) { func setTypeLeftDenotation(tokenType lexer.TokenType, leftDenotation typeLeftDenotationFunc) { current := typeLeftDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "type left denotation for token %s already exists", tokenType, )) @@ -83,7 +83,7 @@ func setTypeLeftDenotation(tokenType lexer.TokenType, leftDenotation typeLeftDen func setTypeMetaLeftDenotation(tokenType lexer.TokenType, metaLeftDenotation typeMetaLeftDenotationFunc) { current := typeMetaLeftDenotations[tokenType] if current != nil { - panic(NewUnpositionedSyntaxError( + panic(errors.NewUnexpectedError( "type meta left denotation for token %s already exists", tokenType, ))