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

-json-errors reports blank error message #3481

Closed
Feoramund opened this issue Apr 24, 2024 · 3 comments · Fixed by #3494
Closed

-json-errors reports blank error message #3481

Feoramund opened this issue Apr 24, 2024 · 3 comments · Fixed by #3494
Labels

Comments

@Feoramund
Copy link
Contributor

Context

For the following erroneous program, Odin reports a second, blank error message on the same line.

package main

main :: proc() {
	a
}
{
	"error_count": 2,
	"errors": [
		{
			"type": "error",
			"pos": {
				"file": "/tmp/odin-error/main.odin",
				"offset": 32,
				"line": 4,
				"column": 2,
				"end_column": 3
			},
			"msgs": [
				"Undeclared name: a"
			]
		},
		{
			"type": "error",
			"pos": {
				"file": "/tmp/odin-error/main.odin",
				"offset": 32,
				"line": 4,
				"column": 2,
				"end_column": 2
			},
			"msgs": [
			]
		}
	]
}
Odin:    dev-2024-04:e3d41f0a9
OS:      Arch Linux, Linux 6.8.7-arch1-1
CPU:     12th Gen Intel(R) Core(TM) i7-12700K
RAM:     31916 MiB
Backend: LLVM 14.0.6
@gingerBill
Copy link
Member

Latest commit?

@Feoramund
Copy link
Contributor Author

Commit e3d41f0. Made sure to re-build. Still occurring.

@gingerBill gingerBill added the bug label Apr 25, 2024
@Feoramund
Copy link
Contributor Author

I did some stack tracing on this one. The 2nd error is arising for the regular console output code path too, but the len check in the following block hides it from any form of output.

Odin/src/error.cpp

Lines 783 to 787 in 8fd318e

for (isize line_idx = 0; /**/; line_idx++) {
String line = string_split_iterator(&it, '\n');
if (line.len == 0) {
break;
}

It seems to be an incidental happenstance that errors with blank messages are skipped over in the regular version, and the json_errors() version has merely revealed the oddity of this occurring. I'm assuming the blank 2nd error is the true error here and not that the JSON version lacks a guard against this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants