fix: infer float context from division

This commit is contained in:
2026-10-22 11:51:48 +02:00
parent bbf39c16c5
commit bc318a29ad
4 changed files with 8 additions and 5 deletions
+3
View File
@@ -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: {}
}
+3 -3
View File
@@ -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