Skip to content

int values incorrectly promoted to f32 #7692

@mareek

Description

@mareek

V version: 0.2
OS: Windows 10 x64

What did you do?
I assigned an int to a mutable f32 variable

mut my_float_32 := f32(3.2)
my_int := int(2147483583)
my_float_32 =  my_int // should fail to compile

What did you expect to see?
I expected a compilation error as implied by the documentation

An int value for example can be automatically promoted to f64 or i64 but not to f32 or u32. (f32 would mean precision loss for large values and u32 would mean loss of the sign for negative values).

What did you see instead?
The code compiled and ran without error but precision was lost

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis tag is applied to issues which reports bugs.Status: ConfirmedThis bug has been confirmed to be valid by a contributor.Unit: CheckerBugs/feature requests, that are related to the type checker.Unit: CompilerBugs/feature requests, that are related to the V compiler in general.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions