File tree 3 files changed +62
-1
lines changed
3 files changed +62
-1
lines changed Original file line number Diff line number Diff line change @@ -345,7 +345,6 @@ func (c *compiler) IntegerNode(node *ast.IntegerNode) {
345
345
}
346
346
c .emitPush (int32 (node .Value ))
347
347
case reflect .Int64 :
348
- panic (fmt .Sprintf ("constant %d overflows int64" , node .Value ))
349
348
c .emitPush (int64 (node .Value ))
350
349
case reflect .Uint :
351
350
if node .Value < 0 {
Original file line number Diff line number Diff line change @@ -628,3 +628,25 @@ func TestCompile_optimizes_jumps(t *testing.T) {
628
628
})
629
629
}
630
630
}
631
+
632
+ func TestCompile_IntegerArgsFunc (t * testing.T ) {
633
+ env := mock.Env {}
634
+ tests := []struct { code string }{
635
+ {"FuncInt(0)" },
636
+ {"FuncInt8(0)" },
637
+ {"FuncInt16(0)" },
638
+ {"FuncInt32(0)" },
639
+ {"FuncInt64(0)" },
640
+ {"FuncUint(0)" },
641
+ {"FuncUint8(0)" },
642
+ {"FuncUint16(0)" },
643
+ {"FuncUint32(0)" },
644
+ {"FuncUint64(0)" },
645
+ }
646
+ for _ , tt := range tests {
647
+ t .Run (tt .code , func (t * testing.T ) {
648
+ _ , err := expr .Compile (tt .code , expr .Env (env ))
649
+ require .NoError (t , err )
650
+ })
651
+ }
652
+ }
Original file line number Diff line number Diff line change @@ -65,6 +65,46 @@ func (p Env) FuncTyped(_ string) int {
65
65
return 2023
66
66
}
67
67
68
+ func (p Env ) FuncInt (_ int ) int {
69
+ return 0
70
+ }
71
+
72
+ func (p Env ) FuncUint (_ uint ) int {
73
+ return 0
74
+ }
75
+
76
+ func (p Env ) FuncInt8 (_ float64 ) int {
77
+ return 0
78
+ }
79
+
80
+ func (p Env ) FuncInt16 (_ int16 ) int {
81
+ return 0
82
+ }
83
+
84
+ func (p Env ) FuncInt32 (_ int32 ) int {
85
+ return 0
86
+ }
87
+
88
+ func (p Env ) FuncInt64 (_ int64 ) int {
89
+ return 0
90
+ }
91
+
92
+ func (p Env ) FuncUint8 (_ uint8 ) int {
93
+ return 0
94
+ }
95
+
96
+ func (p Env ) FuncUint16 (_ uint16 ) int {
97
+ return 0
98
+ }
99
+
100
+ func (p Env ) FuncUint32 (_ uint32 ) int {
101
+ return 0
102
+ }
103
+
104
+ func (p Env ) FuncUint64 (_ uint64 ) int {
105
+ return 0
106
+ }
107
+
68
108
func (p Env ) TimeEqualString (a time.Time , s string ) bool {
69
109
return a .Format ("2006-01-02" ) == s
70
110
}
You can’t perform that action at this time.
0 commit comments