You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
After #92 another issue seems to have been introduced concerning instanceof parsing.
Consider the following template:
{$interface = 'a_random_interface'}{$object = 'a string'}{if$object instanceof $interface||$object instanceof a_random_interface}
<p>$object is an instance of {$interface|escape}</p>
{else}
<p>$object NOT is an instance of {$interface|escape}</p>
{/if}{if!$object instanceof $interface||!$object instanceof a_random_interface}
<p>$object NOT is an instance of {$interface|escape}</p>
{else}
<p>$object is an instance of {$interface|escape}</p>
{/if}
Expected output is:
$object NOT is an instance of a_random_interface
$object NOT is an instance of a_random_interface
This output is produced until Smarty 3.1.21. In following versions an error is given (output is based on Smarty 3.1.29, so after applying the fix for #92):
Fatal error: Uncaught --> Smarty Compiler: Syntax error in template "file:~/templates/correct.tpl" on line 10 "{if !$object instanceof $interface" - Unexpected " instanceof ", expected one of: "}" <-- thrown in ~/vendor/smarty/smarty/libs/sysplugins/smarty_internal_templatecompilerbase.php on line 10
Note that putting parentheses around the instanceof corrects the behaviour:
{if!($object instanceof $interface)||!($object instanceof a_random_interface)}
<p>$object NOT is an instance of {$interface|escape}</p>
{else}
<p>$object is an instance of {$interface|escape}</p>
{/if}
After #92 another issue seems to have been introduced concerning
instanceof
parsing.Consider the following template:
Expected output is:
This output is produced until Smarty 3.1.21. In following versions an error is given (output is based on Smarty 3.1.29, so after applying the fix for #92):
Note that putting parentheses around the
instanceof
corrects the behaviour:Following code is used to render the template:
The text was updated successfully, but these errors were encountered: