SEPURI-SAI-KRISHNA opened a new issue, #12736:
URL: https://github.com/apache/maven/issues/12736

   ### Affected version
   
   4.1.0-SNAPSHOT (master)
   
   ### Bug description
   
   The condition tokenizer in `ConditionParser` treats `!` as an operator 
character. When `!` is
   followed by `=` it emits a single `!=` token; otherwise it emits a bare `!` 
token:
   
   ```java
   } else if (Character.isWhitespace(c) || ... || c == '!' || ...) {
       ...
       } else {
           tokens.add(String.valueOf(c));   // emits a bare "!"
       }
   ```
   
   No parser rule ever consumes that bare `!`. `parseUnary()` handles only `-`, 
so a `!` falls through
   to `parseTerm()`, fails `Double.parseDouble("!")`, and lands in 
`parseVariableOrUnknownFunction()`:
   
   ```
   <condition>!exists('some/path')</condition>
   
   Error parsing profile activation condition: Unknown variable: !
   ```
   
   So the natural spelling of negation produces a confusing error that talks 
about variables. The
   workaround is the `not()` function, which already exists and does exactly 
this:
   
   ```xml
   <condition>not(exists('some/path'))</condition>
   ```
   
   A tokenizer that emits a token no parser rule can consume looks like an 
unfinished implementation
   rather than a deliberate omission. Making `!` sugar for the existing `not()` 
function is a small
   change and adds no new capability.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to