V version:
V playground
OS:
N/A
What did you do?
fn main() {
println(3%1.2)
}
What did you expect to see?
An error
Or a result (eg, in Python)
What did you see instead?
You just found a bug. V can't compile this program, but it should. Please create a GitHub issue.
@SleepyRoy actually for floating-point remainder you need math.fmod(3, 1.2).
@LorenzoPirro Thanks. So I think "3%1.2" should simply gives an error (actually "1.2%3" is handled correctly). Also it might be better that the compiler gives a suggestion of turning to the math module. @medvednikov
@SleepyRoy you're welcome! Yes could be useful
Yes, that has to be fixed. I noticed the error is not cought by V compiler only when you use the literal on the right-hand side. If you assign it to the variable first then try % it gives you an error as expected. Somebody will fix it. Thanks for the issue.
Fixed.
Most helpful comment
Fixed.