fix: infer float context from division
This commit is contained in:
+1
-1
@@ -34,7 +34,7 @@ program ::
|
||||
`z :: "hello"
|
||||
`
|
||||
`a := 1 + 2 * 3
|
||||
`b :: -3.0 / 2 + 1
|
||||
`b :: -3 / 2 + 1
|
||||
`
|
||||
`grouped proc(left, right int, extra float) void {
|
||||
` value int :: later + left
|
||||
|
||||
@@ -179,6 +179,9 @@ check proc(
|
||||
expression :: ast.binary_expr(tree, id)
|
||||
try numeric_operand(&state, id, expression.left)
|
||||
try numeric_operand(&state, id, expression.right)
|
||||
if (expression.operator == .divide) {
|
||||
try impose(&state, id, .float, .integer_division, expression.span)
|
||||
}
|
||||
}
|
||||
else: {}
|
||||
}
|
||||
|
||||
@@ -56,8 +56,8 @@ propagates_numeric_context_before_defaulting_forward_and_mutable_aliases test {
|
||||
`seed := 3
|
||||
`backward :: 4
|
||||
`demand float :: backward
|
||||
`quotient float :: 3 / 2
|
||||
`mixed :: 3.0 / 2
|
||||
`quotient :: -3 / 2 + 1
|
||||
`mixed :: 3 / 2
|
||||
`plain :: -3 + 2 * 4
|
||||
`fraction :: 1.5
|
||||
`text :: "honey"
|
||||
@@ -112,7 +112,7 @@ rejects_fixed_family_conversion_integer_division_and_conflicting_demands test {
|
||||
`widen float :: fixed
|
||||
`narrow int :: 1.5
|
||||
`cross :: fixed + real
|
||||
`division :: 3 / 2
|
||||
`division :: fixed / 2
|
||||
`negated :: -"x"
|
||||
`strings :: "a" + "b"
|
||||
`first_int int :: conflict_a
|
||||
|
||||
Reference in New Issue
Block a user