redhat-developer / quarkus-ls

Language server for Quarkus tooling
Eclipse Public License 2.0
44 stars 15 forks source link

`??` after function invocation in a qute template #837

Open datho7561 opened 1 year ago

datho7561 commented 1 year ago

Given the following template fragment:

{#if !inject:vertxRequest.getParam('sandwich')??}
  no sandwich ;-;
{/}

The ?? is marked with a warning by qute-ls saying it's an invalid object. However, this template renders fine.

fbricon commented 1 year ago

What do you expect the ?? would apply to? What's the priority here? Does it apply to vertxRequest.getParam('sandwich') or the whole !inject expression, which would resolve to a boolean. @mkouba thoughts?

fbricon commented 1 year ago

There's actually the same message for {#if inject:vertxRequest.getParam('sandwich')??}

angelozerr commented 1 year ago

There is the same problem without !

{#if inject:vertxRequest.getParam('sandwich')??}
  no sandwich ;-;
{/}
mkouba commented 1 year ago

What do you expect the ?? would apply to? What's the priority here? Does it apply to vertxRequest.getParam('sandwich') or the whole !inject expression, which would resolve to a boolean. @mkouba thoughts?

?? denotes a "safe expression"; it's just a shorthand notation for .or(null), i.e. inject:vertxRequest.getParam('sandwich')?? becomes inject:vertxRequest.getParam('sandwich').or(null). And null is a valid value, it is considered falsy and outputs an empty string.