Skip to content

Commit d652fbe

Browse files
davixckyantonmedv
andauthored
Throw an error if predicate not present in parser (#842)
Co-authored-by: Anton Medvedev <anton@medv.io>
1 parent daf1790 commit d652fbe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

parser/parser.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ func (p *Parser) parseCall(token Token, arguments []Node, checkOverrides bool) N
550550
}
551551
isOverridden = isOverridden && checkOverrides
552552

553-
if b, ok := predicates[token.Value]; ok && !isOverridden {
553+
if _, ok := predicates[token.Value]; ok && p.config != nil && p.config.Disabled[token.Value] && !isOverridden {
554+
// Disabled predicate without replacement - fail immediately
555+
p.error("unknown name %s", token.Value)
556+
} else if b, ok := predicates[token.Value]; ok && !isOverridden {
554557
p.expect(Bracket, "(")
555558

556559
// In case of the pipe operator, the first argument is the left-hand side
@@ -594,6 +597,9 @@ func (p *Parser) parseCall(token Token, arguments []Node, checkOverrides bool) N
594597
if node == nil {
595598
return nil
596599
}
600+
} else if _, ok := builtin.Index[token.Value]; ok && p.config != nil && p.config.Disabled[token.Value] && !isOverridden {
601+
// Disabled builtin without replacement - fail immediately
602+
p.error("unknown name %s", token.Value)
597603
} else if _, ok := builtin.Index[token.Value]; ok && (p.config == nil || !p.config.Disabled[token.Value]) && !isOverridden {
598604
node = p.createNode(&BuiltinNode{
599605
Name: token.Value,

0 commit comments

Comments
 (0)