You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by "Dmitri Blinov (Jira)" <ji...@apache.org> on 2022/12/10 17:15:00 UTC

[jira] [Created] (JEXL-390) Pragmas should not be statements

Dmitri Blinov created JEXL-390:
----------------------------------

             Summary: Pragmas should not be statements
                 Key: JEXL-390
                 URL: https://issues.apache.org/jira/browse/JEXL-390
             Project: Commons JEXL
          Issue Type: Improvement
            Reporter: Dmitri Blinov


In Jexl pragmas are treated as statements syntactically, but do not find their way to AST tree and this leads to strange bugs like in the following example

{code}
    @Test
    public void testBadPragmas() throws Exception {
        final JexlEngine jexl = new JexlBuilder().cache(1024).debug(true).create();
        final JexlScript script = jexl.createScript("if (true) #pragma one 42");
        JexlContext jc = new MapContext();
        final Object result = script.execute(jc);
        debuggerCheck(jexl);      
    }
{code}

While this partucular bug can be trivially fixed, in fact the whole idea to allow putting pragmas inside a loop or inside if-branch is a strange language design (I'm not aware of examples in other languages) as it gives false idea of the pragma being controlled by script execution logic.

If there's no reason or use case to keep this design as is, my proposal is to make a grammar change and allow pragmas to be declared only at the top of the script  




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