File tree Expand file tree Collapse file tree 3 files changed +20
-6
lines changed
Expand file tree Collapse file tree 3 files changed +20
-6
lines changed Original file line number Diff line number Diff line change @@ -690,21 +690,21 @@ private Optional<CelExpr> visitMacro(
690690 }
691691
692692 private String normalizeEscapedIdent (EscapeIdentContext context ) {
693+ String identifier = context .getText ();
693694 if (context instanceof SimpleIdentifierContext ) {
694- return (( SimpleIdentifierContext ) context ). getText () ;
695+ return identifier ;
695696 } else if (context instanceof EscapedIdentifierContext ) {
696697 if (!options .enableQuotedIdentifierSyntax ()) {
697698 exprFactory .reportError (context , "unsupported syntax '`'" );
698- return "" ;
699+ return identifier ;
699700 }
700- String escaped = ((EscapedIdentifierContext ) context ).getText ();
701- return escaped .substring (1 , escaped .length () - 1 );
701+ return identifier .substring (1 , identifier .length () - 1 );
702702 }
703703
704704 // This is normally unreachable, but might happen if the parser is in an error state or if the
705705 // grammar is updated and not handled here.
706706 exprFactory .reportError (context , "unsupported identifier" );
707- return "" ;
707+ return identifier ;
708708 }
709709
710710 private CelExpr .CelStruct .Builder visitStructFields (FieldInitializerListContext context ) {
Original file line number Diff line number Diff line change @@ -296,10 +296,12 @@ public void parser_errors() {
296296
297297 CelParser parserWithoutQuotedFields =
298298 CelParserImpl .newBuilder ()
299+ .setStandardMacros (CelStandardMacro .HAS )
299300 .setOptions (CelOptions .current ().enableQuotedIdentifierSyntax (false ).build ())
300301 .build ();
301302 runTest (parserWithoutQuotedFields , "foo.`bar`" );
302303 runTest (parserWithoutQuotedFields , "Struct{`bar`: false}" );
304+ runTest (parserWithoutQuotedFields , "has(.`.`" );
303305 }
304306
305307 @ Test
Original file line number Diff line number Diff line change @@ -332,4 +332,16 @@ I: Struct{`bar`: false}
332332=====>
333333E: ERROR: <input>:1:8: unsupported syntax '`'
334334 | Struct{`bar`: false}
335- | .......^
335+ | .......^
336+
337+ I: has(.`.`
338+ =====>
339+ E: ERROR: <input>:1:6: no viable alternative at input '.`.`'
340+ | has(.`.`
341+ | .....^
342+ ERROR: <input>:1:6: unsupported syntax '`'
343+ | has(.`.`
344+ | .....^
345+ ERROR: <input>:1:9: missing ')' at '<EOF>'
346+ | has(.`.`
347+ | ........^
You can’t perform that action at this time.
0 commit comments