Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silent Conversion of u64 to f64 #21778

Open
mike-ward opened this issue Jul 1, 2024 · 1 comment
Open

Silent Conversion of u64 to f64 #21778

mike-ward opened this issue Jul 1, 2024 · 1 comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker.

Comments

@mike-ward
Copy link
Contributor

mike-ward commented Jul 1, 2024

Describe the bug

Compiler quietly converts u64 to f64 in or clause

Reproduction Steps

mut num := f64(0.0)
num = strconv.atof64(some_string) or { strconv.double_minus_infinity }

strconv.double_minus_infinity is u64. This compiles OK but I feel it should be an error because a u64 is converted to a f64 in the or clause

Expected Behavior

Compiler should issue an error about the conversion.

Current Behavior

Code compiles without warning or error

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.6 fccd7cd

Environment details (OS name and version, etc.)

V full version: V 0.4.6 8215f21.fccd7cd
OS: macos, macOS, 14.5, 23F79
Processor: 8 cpus, 64bit, little endian, Apple M2

getwd: /Users/mike/Documents/github/coreutils/src/sort
vexe: /Users/mike/Documents/github/v/v
vexe mtime: 2024-06-27 19:39:41

vroot: OK, value: /Users/mike/Documents/github/v
VMODULES: OK, value: /Users/mike/.vmodules
VTMP: OK, value: /tmp/v_501

Git version: git version 2.45.2
Git vroot status: weekly.2024.26-11-gfccd7cd0 (11 commit(s) behind V master)
.git/config present: true

CC version: Apple clang version 15.0.0 (clang-1500.3.9.4)
thirdparty/tcc status: thirdparty-macos-arm64 5c1d002f

Note

You can use the 👍 reaction to increase the issue's priority for developers.

Please note that only the 👍 reaction to the issue itself counts as a vote.
Other reactions and those to comments will not be taken into account.

@mike-ward mike-ward added the Bug This tag is applied to issues which reports bugs. label Jul 1, 2024
@felipensp felipensp added the Unit: Checker Bugs/feature requests, that are related to the type checker. label Jul 3, 2024
@hholst80
Copy link
Contributor

hholst80 commented Sep 6, 2024

The intent is probably that these constants should be of f64 type.

// f64 constants
pub const digits = 18
pub const double_plus_zero = u64(0x0000000000000000)
pub const double_minus_zero = u64(0x8000000000000000)
pub const double_plus_infinity = u64(0x7FF0000000000000)
pub const double_minus_infinity = u64(0xFFF0000000000000)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug This tag is applied to issues which reports bugs. Unit: Checker Bugs/feature requests, that are related to the type checker.
Projects
None yet
Development

No branches or pull requests

3 participants