V version: 0.1.26 9e715b8
OS: Windows
What did you do?
test.v and write the code below.v test.v or v run test.vtest.v
// Comment line 1
// Comment line 2
fn func1() {
println('Inside func 1')
}
fn main() {
func1()
a = 2
println('a is $a')
}
What did you expect to see?
Syntax error on lines 9 and 10. And an error message similar to:
test.v:9:5: error: undefined: `a`
7 | fn main() {
8 | func1()
9 | a = 2
| ^
10 | println('a is $a')
11 | }
test.v:10:20: error: undefined: `a`
8 | func1()
9 | a = 2
10 | println('a is $a')
| ^
11 | }
What did you see instead?
Syntax error reason is correct but on the wrong line numbers. 7 instead of 9 and 8 instead of 10.
.\test.v:7:2: error: undefined: `a`
5 | }
6 |
7 | fn main() {
| ^
8 | func1()
9 | a = 2
.\test.v:8:17: error: undefined: `a`
6 |
7 | fn main() {
8 | func1()
|
9 | a = 2
10 | println('a is $a')
Win10 1909
V 0.1.26 24aff9e.67a50b5
D:\test\v\tt1>v run .
.\tt1.v:9:2: error: undefined: `a`
7 | fn main() {
8 | func1()
9 | a = 2
| ^
10 | println('a is $a')
11 | }
.\tt1.v:10:17: error: undefined: `a`
8 | func1()
9 | a = 2
10 | println('a is $a')
| ^
11 | }
No problems.
Strange. I removed V, re-downloaded and built everything. But the bug persists.
Can reproduce on ArchLinux with V 0.1.27 02fb393 and c4fbae3 (GCC 10.1.0).
You need to use \r\n line endings to reproduce this bug.
v fmt _should_ convert \r\n to just \n. \n is the official EOL for v.
However, it would be nice if v itself treated \r\n as \n, in case you haven't run v fmt yet.
In the meantime, most Windows editors can be set to only output \n line endings.
I can reproduce this with V 0.1.28 bbaf6e3.
If the comment lines are removed, then the line numbers are correct.
Fixed in 47f59d3
@spytheman thanks!
Most helpful comment
Fixed in 47f59d3