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

Improve error reporting on invalid code #21064

Open
hholst80 opened this issue Mar 19, 2024 · 0 comments
Open

Improve error reporting on invalid code #21064

hholst80 opened this issue Mar 19, 2024 · 0 comments
Labels
Bug This tag is applied to issues which reports bugs.

Comments

@hholst80
Copy link
Contributor

hholst80 commented Mar 19, 2024

Describe the bug

The following invalid code gives poor error reports:

fn main() {
	dummy := map[string][bool] // invalid syntax should be map[string]bool{}
	for i := 0; i < 10; i++ {
	}
}

Reproduction Steps

[I] root@trump ~ [1]
# v fmt -w e.v
e.v:2:24: error: maps can only have a single key
    1 | fn main() {
    2 |   dummy := map[string][bool]
      |                        ~~~~
    3 |   for i := 0; i < 10; i++ {
    4 |   }

Internal vfmt error while formatting file: e.v.
Encountered a total of: 1 errors.
[I] root@trump ~ [1]
# v e.v
e.v:3:15: error: expression evaluated but not used
    1 | fn main() {
    2 |   dummy := map[string][bool]
    3 |   for i := 0; i < 10; i++ {
      |               ~~~~~~
    4 |   }
    5 | }

Expected Behavior

I would like to see "syntax error" or something more non-spurious.
The compiler should not point out the for-loop below for sure.

Current Behavior

See above.

Possible Solution

No response

Additional Information/Context

No response

V version

V 0.4.4 cf7dcfe

Environment details (OS name and version, etc.)

V full version: V 0.4.4 cf7dcfe
OS: linux, "Artix Linux"
Processor: 4 cpus, 64bit, little endian, Intel(R) Core(TM) i7-6600U CPU @ 2.60GHz

getwd: /home/root
vexe: /home/root/Apps/v/v
vexe mtime: 2024-02-27 14:30:38

vroot: OK, value: /home/root/Apps/v
VMODULES: OK, value: /home/root/.vmodules
VTMP: OK, value: /tmp/v_0

Git version: git version 2.43.1
Git vroot status: weekly.2024.10-3-ga867ed6a (57 commit(s) behind V master)
.git/config present: true

CC version: cc (GCC) 13.2.1 20230801
thirdparty/tcc status: thirdparty-linux-amd64 40e5cbb5

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.

@hholst80 hholst80 added the Bug This tag is applied to issues which reports bugs. label Mar 19, 2024
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.
Projects
None yet
Development

No branches or pull requests

1 participant