mesour-intellij-plugins / latte-pro-issues

2 stars 0 forks source link

Variable usage detection broken for code inside {foreach} in {block} #159

Open nufue opened 3 months ago

nufue commented 3 months ago

Describe the bug The detection of usage of variables created via {var} seems to be broken when usage occurs inside {foreach} while the whole template is enclosed in {block}..{/block}.

Environment (please complete the following information):

To Reproduce

  1. Paste code below to a new file.
  2. See that $level in {var $level = 0} is hinted as unused variable, which is not true, as it is used inside of {foreach}. Also $level in {php $level++} is marked as Undefined variable.

Code

{block content}
    {var $level = 0}
    {foreach $groups as $value}
        {php $level++}
    {/foreach}
{/block}

Screenshots image

Additional context If I remove {block content} and {/block} from the code, the variable is no longer marked as unused.

SendiMyrkr commented 3 months ago

Same problem is for {if} inside {define} unused-undefined-variables

Marian-Kechlibar commented 1 month ago

Same with printing.

An element of an array is indicated as "Print invalid type: array" in Inspection, as if I were trying to print the entire array.

A variable that is declared as default null is indicated as "Print invalid type: null", even though the printout occurs in n:ifset="" condition that rules out the value of null.

Marian-Kechlibar commented 1 month ago

Also, the inspection for print invalid type is named "Tag var content". There are two such entries in Inspections / Latte / Not allowed, one of them actually checks tag var content, the other checks invalid printing types.

This is obviously a minor misprint, copied value from an older inspection, still a bit confusing if you want to turn the broken printing detections off.