Invalid operator in expression sees `parse()` successfully
Using the latest release of cel-js v0.8.2, I was attempting to see how the parser handled invalid expressions, and discovered that the following appears to parse successfully:
import { parse } from 'cel-js'
const result = parse("value =< 42") // Should be invalid syntax as =< is not an operator
console.log(result)
Output:
{
isSuccess: true,
cst: {
name: 'expr',
children: [Object: null prototype] { conditionalOr: [Array] }
}
}
The expression is invalid expression as the operator =< does not exist - a real-world typo.
By contrast, this errors within Go, tested with https://github.com/google/cel-go v0.26.1:
package main
import (
"log"
"github.com/google/cel-go/cel"
)
func main() {
env, err := cel.NewEnv()
if err != nil {
log.Fatal(err)
}
_, issues := env.Compile("value =< 42")
if issues != nil && issues.Err() != nil {
log.Fatalf("type-check error: %s", issues.Err())
}
}
2025/09/30 09:57:03 type-check error: ERROR: <input>:1:7: Syntax error: token recognition error at: '=<'
| value =< 42
| ......^
ERROR: <input>:1:10: Syntax error: extraneous input '42' expecting <EOF>
| value =< 42
| .........^
exit status 1
Hi @davidjb ,
Nice catch, legit bug.
Can you open PR to fix it? Currently I have very limited time, I don't now when it will be fixed 😬
Thanks for getting back to me so quickly. Unfortunately, I'm not in a position to create a PR at this stage, I was just scouting for potential CEL libraries and encountered the issue as my very first call to parse(). Hopefully someone else can dive in and help you though!