go-datemath icon indicating copy to clipboard operation
go-datemath copied to clipboard

scanner internal error

Open kolaente opened this issue 1 year ago • 1 comments

I got this panic in using the library: scanner internal error. It looks like it is coming from here:

https://github.com/vectordotdev/go-datemath/blob/master/datemath.l.go#L341

It seems to be caused by passing in an invalid expression like "no" instead of "now" into the parser function. In my opinion, this should be caught earlier and be a regular error message instead of flat-out panicking. Besides, the comment above the panic in code says how this should never happen - and yet it does.

kolaente avatar Apr 02 '23 11:04 kolaente

Thanks for reporting this @kolaente !

I was able to verify this panic. The code you are reference is generated code. The fix should go in the source lex file: https://github.com/vectordotdev/go-datemath/blob/master/datemath.l

jszwedko avatar Apr 11 '23 23:04 jszwedko