Open romshark opened 3 years ago
In case of rule redeclaration the generator should return an error:
package main type parser Peg { } main <- (a)+ a <- 'a' a <- 'a'
The invalid grammar crashes the generator due to a segmentation fault:
romanscharkov@RomMac pegbug % peg grammar.peg panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x1164e55] goroutine 1 [running]: github.com/pointlander/peg/tree.(*Tree).Compile(0xc000074000, 0xc00001a0e0, 0xe, 0xc00000c060, 0x2, 0x2, 0x1200e60, 0xc00000e030, 0x0, 0x0) /Users/romanscharkov/go/src/github.com/pointlander/peg/tree/peg.go:1506 +0x1475 main.main() /Users/romanscharkov/go/src/github.com/pointlander/peg/main.go:87 +0x575
Expected behavior
In case of rule redeclaration the generator should return an error:
Actual behavior
The invalid grammar crashes the generator due to a segmentation fault: