Closed mwmuni closed 10 months ago
const zoom_factor = 1.1
fn abc(zoom_factor f64) {
a := if zoom_factor < 1 { 1 } else { -1 }
dump(a)
}
fn def(zfactor f64) {
a := if zfactor < 1 { 1 } else { -1 }
dump(a)
}
fn main() {
abc(0.1)
def(0.1)
}
This can be used as a simpler test for the regression. Both functions should print the same value, but instead:
[f64_const_relations.v:5] a: -1
[f64_const_relations.v:10] a: 1
Describe the bug
In the Mandelbrot example, attempting to scroll up or down results in only zooming out. The
zoom
function takes in thezoom_factor
argument of typef64
, however it does not behave normally.link to Mandelbrot zoom function
println(zoom_factor)
->0.9090909090909091
println(typeof(zoom_factor))
->f64
zoom_factor < 1
->false
zoom_factor < 1.0
->false
f64(zoom_factor) < 1
->true
f64(zoom_factor) < 1.0
->true
Despite already being an
f64
,zoom_factor
does not function correctly until cast as anf64
again.Unfortunately, fixing this issue still results in the Mandlebrot only zooming out despite the
state.scale
increasing.Reproduction Steps
https://github.com/vlang/v/blob/2ef49b8c1126081c6584d9dd747f99cc231d514e/examples/gg/mandelbrot.v#L132
println(zoom_factor) println(typeof(zoom_factor)) println(zoom_factor < 1) println(zoom_factor < 1.0) println(f64(zoom_factor) < 1) println(f64(zoom_factor) < 1.0)
Expected Behavior
all evaluate to true
Current Behavior
evaluates to false unless recast as f64
Possible Solution
A git bisect identified the bad commit as: 055e113af37017a5bbc9173b17cecbe556b79b39
I have made a pull request that comments out the lines causing the bug #19773
Additional Information/Context
Issue is not present using V 0.4.1, with the same
mandelbrot.v
file https://github.com/vlang/v/commit/0e2dc381ab74f2e74996507b930e93b876517a95V version
0.4.2 fbefe68
Environment details (OS name and version, etc.)
V full version: V 0.4.2 fbefe68 OS: windows, Microsoft Windows 11 Pro v22621 64-bit Processor: 16 cpus, 64bit, little endian,
getwd: C:\Users\matt\Documents_scripts\repos\v\examples vexe: C:\Users\matt\Documents_scripts\repos\v\v.exe vexe mtime: 2023-11-03 16:35:02
vroot: OK, value: C:\Users\matt\Documents_scripts\repos\v VMODULES: OK, value: C:\Users\matt.vmodules VTMP: OK, value: C:\Users\matt_\AppData\Local\Temp\v_0
Git version: git version 2.37.2.windows.2 Git vroot status: weekly.2023.44-30-gfbefe685-dirty (16 commit(s) behind V master) .git/config present: true
CC version: Error: 'cc' is not recognized as an internal or external command, operable program or batch file.
thirdparty/tcc status: thirdparty-windows-amd64 e90c2620