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

Cannot report an error about spelling inconsistencies of kind names #5

Closed
nihei9 opened this issue Mar 21, 2022 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@nihei9
Copy link
Owner

nihei9 commented Mar 21, 2022

When kind names contain spelling inconsistencies, maleeni v0.6.0 panics.

I made the following file:

{
	"name": "test",
	"entries": [
		{
			"kind": "foo_1",
			"pattern": "foo_1"
		},
		{
			"kind": "foo1",
			"pattern": "foo1"
		}
	]
}

Then I got the following error:

$ maleeni compile test.json
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x5262bb]

goroutine 1 [running]:
github.com/nihei9/maleeni/spec.findSpellingInconsistenciesErrors(0xc0001b83c0, 0x3, 0x4, 0x0, 0x3, 0xc0001b83c0, 0x2)
        /home/nihei9/src/github.com/nihei9/maleeni/spec/spec.go:259 +0xdb
github.com/nihei9/maleeni/spec.(*LexSpec).Validate(0xc0001830e0, 0x0, 0x200)
        /home/nihei9/src/github.com/nihei9/maleeni/spec/spec.go:225 +0xb28
github.com/nihei9/maleeni/compiler.Compile(0xc0001830e0, 0xc000217d18, 0x1, 0x1, 0x0, 0xc000226100, 0xc000217d10, 0xc000217d38, 0xc000217d38, 0x5cd045)
        /home/nihei9/src/github.com/nihei9/maleeni/compiler/compiler.go:37 +0x45
main.runCompile(0xc0001bef00, 0xc000183050, 0x1, 0x3, 0x0, 0x0)
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/compile.go:49 +0xe5
github.com/spf13/cobra.(*Command).execute(0xc0001bef00, 0xc000183020, 0x3, 0x3, 0xc0001bef00, 0xc000183020)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:852 +0x472
github.com/spf13/cobra.(*Command).ExecuteC(0x800100, 0x4626e0, 0xc0000526ef, 0xc000028800)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:960 +0x375
github.com/spf13/cobra.(*Command).Execute(...)
        /home/nihei9/go/pkg/mod/github.com/spf13/cobra@v1.1.3/command.go:897
main.Execute(0x7e9d88, 0xc00010e058)
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/root.go:22 +0x31
main.main()
        /home/nihei9/src/github.com/nihei9/maleeni/cmd/maleeni/main.go:8 +0x25

The expectation is that maleeni compile command prints an error message without panic.

@nihei9 nihei9 added the bug Something isn't working label Mar 21, 2022
@nihei9
Copy link
Owner Author

nihei9 commented Mar 21, 2022

The commit fe865a8 has caused this bug.

hook variable passed to findSpellingInconsistenciesErrors function can be nil, so the function must check whether the variable is nil or not before using it.

@nihei9 nihei9 closed this as completed in f6b90c9 Mar 21, 2022
nihei9 added a commit that referenced this issue Mar 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant