Skip to content

Commit a3bd3a1

Browse files
committed
Do not set int type for 1/0 expression
1 parent d0d972b commit a3bd3a1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

checker/checker_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,11 @@ cannot use float64 as type string in map key (1:4)
499499
cannot use float64 as type int in map key (1:5)
500500
| 1/2 in MapIntAny
501501
| ....^
502+
503+
repeat("0", 1/0)
504+
cannot use float64 as argument (type int) to call repeat (1:14)
505+
| repeat("0", 1/0)
506+
| .............^
502507
`
503508

504509
func TestCheck_error(t *testing.T) {

checker/types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ func isIntegerOrArithmeticOperation(node ast.Node) bool {
241241
}
242242
case *ast.BinaryNode:
243243
switch n.Operator {
244-
case "+", "/", "-", "*":
244+
case "+", "-", "*":
245245
return true
246246
}
247247
}

0 commit comments

Comments
 (0)