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

Grouped boolean rule parsing fails #1240

Open
vkaverin opened this issue Dec 16, 2024 · 0 comments
Open

Grouped boolean rule parsing fails #1240

vkaverin opened this issue Dec 16, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@vkaverin
Copy link

PHP Version: 7.4.28

OS: Linux

The minimal code in which the bug appears:

function alwaysX() {

  /** @warning Probably this expression is always true */
  always_true: {
    $x || true;
    true || $x;
  }
}

Actual Behavior:

15:36:45 Panic while parsing /home/vkaverin/data/codestyle/rules/debug.php: unhandled node: x=*ir.LabelStmt y=*ir.LabelStmt (please, fill an issue on GitHub)


Stack trace: goroutine 611 [running]:
runtime/debug.Stack(0xc0344405f8, 0xb4f380, 0xc0eab33b90)
	/usr/local/go/src/runtime/debug/stack.go:24 +0x9f
github.com/VKCOM/noverify/src/linter.(*Worker).ParseContents.func1(0xc0b19e4000, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc034441d30)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/worker.go:95 +0x76
panic(0xb4f380, 0xc0eab33b90)
	/usr/local/go/src/runtime/panic.go:965 +0x1b9
github.com/VKCOM/noverify/src/phpgrep.(*matcher).eqNode(0xc00305fb00, 0xc034440b20, 0xd55798, 0xc0030654a0, 0xd55798, 0xc0eb79edf8, 0x8)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/phpgrep/matcher.go:785 +0x7c0e
github.com/VKCOM/noverify/src/phpgrep.(*matcher).match(0xc00305fb00, 0xc034440b20, 0xd55798, 0xc0eb79edf8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x3)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/phpgrep/matcher.go:36 +0x7f
github.com/VKCOM/noverify/src/phpgrep.(*Matcher).Match(...)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/phpgrep/phpgrep.go:59
github.com/VKCOM/noverify/src/linter.(*rootWalker).runRule(0xc03cfca900, 0xd55798, 0xc0eb79edf8, 0xc0eab33b60, 0xc0a72d0000, 0xc0eb79edf8)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/root.go:1786 +0xc7
github.com/VKCOM/noverify/src/linter.(*rootWalker).runRules(0xc03cfca900, 0xd55798, 0xc0eb79edf8, 0xc0eab33b60, 0xc0a72d0000, 0x1, 0x1)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/root.go:1746 +0x7b
github.com/VKCOM/noverify/src/linter.(*blockWalker).EnterNode(0xc0daa960b0, 0xd55798, 0xc0eb79edf8, 0xc0d99fa1b0)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/block.go:500 +0x346
github.com/VKCOM/noverify/src/ir.(*LabelStmt).Walk(0xc0eb79edf8, 0xd56350, 0xc0daa960b0)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/ir/walk.go:1097 +0x4b
github.com/VKCOM/noverify/src/linter.(*rootWalker).handleFuncStmts(0xc03cfca900, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc043f8e140, 0x2, 0x2, ...)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/root.go:450 +0x498
github.com/VKCOM/noverify/src/linter.(*rootChecker).CheckFunction(0xc0e58bb080, 0xc042a9ec30, 0xc042a9ec30)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/root_checker.go:88 +0x5b3
github.com/VKCOM/noverify/src/linter.(*rootWalker).EnterNode(0xc03cfca900, 0xd554f0, 0xc042a9ec30, 0xc0b19e4000)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/root.go:229 +0xff6
github.com/VKCOM/noverify/src/ir.(*FunctionStmt).Walk(0xc042a9ec30, 0xd56378, 0xc03cfca900)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/ir/walk.go:888 +0x4b
github.com/VKCOM/noverify/src/ir.(*Root).Walk(0xc0976262a0, 0xd56378, 0xc03cfca900)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/ir/walk.go:1533 +0xac
github.com/VKCOM/noverify/src/linter.(*Worker).analyzeFile(0xc094fb79a0, 0xc0e58bafc0, 0xc0976262a0, 0x16d, 0x16d, 0xc0e58bafc0)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/worker.go:312 +0x4e5
github.com/VKCOM/noverify/src/linter.(*Worker).ParseContents(0xc094fb79a0, 0xc0b19e4000, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/worker.go:143 +0x5f8
github.com/VKCOM/noverify/src/linter.(*Worker).doParseFile(0xc094fb79a0, 0xc0b19e4000, 0x2d, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/worker.go:256 +0x11b
github.com/VKCOM/noverify/src/linter.(*Linter).analyzeFiles.func3(0xc0a27b2101, 0xc00000c690, 0xc001c7fc20, 0xc0a27b20c0, 0xc0a27b2120, 0xc0d42dc870, 0x0)
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/linter.go:104 +0x21e
created by github.com/VKCOM/noverify/src/linter.(*Linter).analyzeFiles
	/go/pkg/mod/github.com/!v!k!c!o!m/noverify@v0.5.4-0.20241205150035-0e43314ec980/src/linter/linter.go:94 +0x25f

Expected Behavior:

Nothing bad happens.

Details:

Separated rule works well:

function alwaysX() {
  /** @warning Probably this expression is always true */
  $x || true; 

  /** @warning Probably this expression is always true */
  true || $x;
}
@vkaverin vkaverin added the bug Something isn't working label Dec 16, 2024
@Hidanio Hidanio self-assigned this Dec 16, 2024
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

2 participants