Repository navigation
D181: an integer beside a float is the float (§4.2.6) - #2919
Merged
Merged
Conversation
Eric, on `let p = i / 140.0` being refused: "dividing an integer by a float should be a float." Integer-to-float conversion is implicit in arithmetic, comparison and where a float is demanded; the result of mixed arithmetic is the float; float-to-integer stays explicit (`as` truncates, `.round() as` rounds). - Sema: implicit_numeric_join returns the float for an integer-and-float pair, so arithmetic and comparison take it from one place; a float demand accepts an integer value. The two "no implicit integer-to-float conversion" diagnostics are gone. - Codegen: a store into a float destination converts an integer with its source's signedness (mir_coerce_value_to_sema_type; the array-literal element and union-field stores pass it); coerce_value_to_type has the signed default. The operation path already converted. - §4.2.6 states the rule (wording for Eric to bless); the decision log has D181; the two #1803 fixtures that pinned the refusal became behav_d181_int_beside_float_is_float.w (division, multiplication, a typed element, u32 and i32 into floats, a comparison, an argument).
ehartford
marked this pull request as ready for review
November 2, 2026 02:46
Contributor
Author
|
Battery GREEN on e6489bc (seed-driven, tools/battery.w); gate green before it. The §4.2.6 wording and the D181 entry are drafted for Eric's blessing. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eric, on
let p = i / 140.0being refused: "dividing an integer by afloat should be a float." Integer-to-float conversion is implicit in
arithmetic, comparison and where a float is demanded; the result of mixed
arithmetic is the float; float-to-integer stays explicit (
astruncates,.round() asrounds).pair, so arithmetic and comparison take it from one place; a float
demand accepts an integer value. The two "no implicit integer-to-float
conversion" diagnostics are gone.
source's signedness (mir_coerce_value_to_sema_type; the array-literal
element and union-field stores pass it); coerce_value_to_type has the
signed default. The operation path already converted.
has D181; the two Sema: implicit integer narrowing is diagnosed only for an annotated
let; sequence/tuple/struct literal elements, call arguments, return values and global initializers narrow silently #1803 fixtures that pinned the refusal becamebehav_d181_int_beside_float_is_float.w (division, multiplication, a
typed element, u32 and i32 into floats, a comparison, an argument).