mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-11-10 04:57:26 +01:00
add tests for shift op: untyped const with typed const
This commit is contained in:
parent
b0a7fb36c7
commit
94bd02af48
@ -153,9 +153,9 @@ func (cs *compileState) parseExpr(block *block, fname string, expr ast.Expr, mar
|
||||
shift, ok := gconstant.Int64Val(rhs[0].Const)
|
||||
if !ok {
|
||||
cs.addError(e.Pos(), fmt.Sprintf("unexpected %s type for: %s", rhs[0].Const.String(), e.Op))
|
||||
} else {
|
||||
v = gconstant.Shift(lhs[0].Const, op, uint(shift))
|
||||
return nil, nil, nil, false
|
||||
}
|
||||
v = gconstant.Shift(lhs[0].Const, op, uint(shift))
|
||||
default:
|
||||
v = gconstant.BinaryOp(lhs[0].Const, op, rhs[0].Const)
|
||||
}
|
||||
|
@ -1324,6 +1324,9 @@ func TestSyntaxOperatorShift(t *testing.T) {
|
||||
{stmt: "a := 1 << 2.0; _ = a", err: false},
|
||||
{stmt: "a := 1.0 << 2; _ = a", err: false},
|
||||
{stmt: "a := 1.0 << 2.0; _ = a", err: false},
|
||||
{stmt: "a := 1.0 << int(1); _ = a", err: false},
|
||||
{stmt: "a := int(1) << 2.0; _ = a", err: false},
|
||||
{stmt: "a := ivec2(1) << 2.0; _ = a", err: false},
|
||||
{stmt: "var a = 1; b := a << 2.0; _ = b", err: false},
|
||||
{stmt: "var a = 1; b := 2.0 << a; _ = b", err: false}, // PR: #2916
|
||||
{stmt: "a := float(1.0) << 2; _ = a", err: true},
|
||||
@ -1351,6 +1354,9 @@ func TestSyntaxOperatorShift(t *testing.T) {
|
||||
{stmt: "a := 1 >> 2.0; _ = a", err: false},
|
||||
{stmt: "a := 1.0 >> 2; _ = a", err: false},
|
||||
{stmt: "a := 1.0 >> 2.0; _ = a", err: false},
|
||||
{stmt: "a := 1.0 >> int(1); _ = a", err: false},
|
||||
{stmt: "a := int(1) >> 2.0; _ = a", err: false},
|
||||
{stmt: "a := ivec2(1) >> 2.0; _ = a", err: false},
|
||||
{stmt: "var a = 1; b := a >> 2.0; _ = b", err: false},
|
||||
{stmt: "var a = 1; b := 2.0 >> a; _ = b", err: false}, // PR: #2916
|
||||
{stmt: "a := float(1.0) >> 2; _ = a", err: true},
|
||||
|
Loading…
Reference in New Issue
Block a user