Poor compilation warning for error propogation in loop #19630
Labels
Bug
This tag is applied to issues which reports bugs.
Nicer V Errors
Bugs/feature requests, related to improving V error messages.
Result Type
Bugs/feature requests, that are related to `!Type`.
Unit: cgen
Bugs/feature requests, that are related to the default C generating backend.
Unit: Checker
Bugs/feature requests, that are related to the type checker.
Describe the bug
When using an error propagation in a for loop, I get an error message:
This is very unhelpful in debugging and finding the error, and confusing to newcomers to vlang like me. Ideally, we'd get something similar to when trying to use the alternative
or
for options.Reproduction Steps
Run each each of the loops below with
v -cg .
Expected Behavior
Output the same or similar
options are not allowed in 'for statement increment' (yet)
as when using error propagation in for loop.Current Behavior
Compilation fails with warnings:
and
Possible Solution
Might be possible to handle this the same way
v
checks for thefor i :=0; i < 10; i = foo! { or 5 }
Additional Information/Context
No response
V version
V 0.4.2 65d7126
Environment details (OS name and version, etc.)
V full version: V 0.4.2 7e2d737.65d7126
OS: linux, Ubuntu 22.04.3 LTS
Processor: 16 cpus, 64bit, little endian, 13th Gen Intel(R) Core(TM) i7-1360P
getwd: /home/wrinkle/workspaces/joshmeranda/vsweeper
vexe: /home/wrinkle/workspaces/vlang/v/v
vexe mtime: 2023-10-23 01:52:31
vroot: OK, value: /home/wrinkle/workspaces/vlang/v
VMODULES: OK, value: /home/wrinkle/.vmodules
VTMP: OK, value: /tmp/v_1001
Git version: git version 2.34.1
Git vroot status: weekly.2023.42-28-g65d71269
.git/config present: true
CC version: cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
thirdparty/tcc status: thirdparty-linux-amd64 12f392c3
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.
The text was updated successfully, but these errors were encountered: