You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Henri Biestro (Jira)" <ji...@apache.org> on 2023/02/28 18:01:00 UTC

[jira] [Resolved] (JEXL-393) const must not be modifiable

     [ https://issues.apache.org/jira/browse/JEXL-393?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Henri Biestro resolved JEXL-393.
--------------------------------
    Resolution: Fixed

Good catch, thanks for the report; the original unit test had a bug (using cont instead of const...). And the solution was a bit more involved than anticipated.
Determining if a variable is const requires going through the stack of lexical units and eventually follow captured variables in their functional scope. The association between the lexical unit (block, for) and the scope was missing; the parser uses a map to maintain it.

https://github.com/apache/commons-jexl/commit/ed41476588a2e28c661394ccf6827185c9a9a65c

> const must not be modifiable
> ----------------------------
>
>                 Key: JEXL-393
>                 URL: https://issues.apache.org/jira/browse/JEXL-393
>             Project: Commons JEXL
>          Issue Type: Bug
>            Reporter: Hussachai Puripunpinyo
>            Assignee: Henri Biestro
>            Priority: Major
>             Fix For: 3.3
>
>
> The following code works with JEXL master (2022-02-21) when it's not supposed to.
> {code:java}
> const total = 0;
> if (true) {
>   total = 1;
> }
> total;  {code}
> At the end, this script yields 1 as total constant was treated as a variable.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)