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

Refine error message with assignments #83

Open
sonalmahajan15 opened this issue Oct 12, 2023 · 0 comments · Fixed by #87
Open

Refine error message with assignments #83

sonalmahajan15 opened this issue Oct 12, 2023 · 0 comments · Fixed by #87
Labels
enhancement New feature or request

Comments

@sonalmahajan15
Copy link
Contributor

For code example below,

func foo(x *int) {
	x = nil
	y := x
	z := y
	print(*z) // L30. Error reported here
}

NilAway prints the error message as

Potential nil panic detected. Observed nil flow from source to dereference point: 
        	-> errormessage/errormessage.go:30:9: literal `nil` dereferenced

This can be confusing and difficult for the users to comprehend if the assignments have followed a complicated path. Instead, we would like NilAway to generate a more informative error message following the assignments.

@sonalmahajan15 sonalmahajan15 linked a pull request Oct 22, 2023 that will close this issue
@sonalmahajan15 sonalmahajan15 added the enhancement New feature or request label Dec 5, 2023
sonalmahajan15 added a commit that referenced this issue Jan 17, 2024
This PR refines the error message by incorporating information about the
assignments. Following is an example of an informative error message:

Code snippet:
```
func test(x *int) {
	x = nil
	y := x
	z := y
	print(*z)
}
```

Error message:
```
Potential nil panic detected. Observed nil flow from source to dereference point: 
   -> errormessage/errormessage.go:32:9: literal `nil` dereferenced via the assignment(s):
        -> `nil` to `x` at errormessage/errormessage.go:29:2,
        -> `x` to `y` at errormessage/errormessage.go:30:2,
        -> `y` to `z` at errormessage/errormessage.go:31:2
```

[closes #83 ]
[depends on #86 ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant