MVEL
  1. MVEL
  2. MVEL-232

for loop compilation issue in strict mode

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0.18
    • Fix Version/s: 2.0.18
    • Component/s: Parser
    • Labels:
      None
    • Number of attachments :
      0

      Description

      The following expression does not compile when strict mode is enabled :

      for(int i=0;i<2;i++) {
        System.out.println(i+"");
      }
      return true;
      

      I get the following error :

      [Error: Failed to compile: 1 compilation error(s): 
       - (1,1) unqualified type in strict mode for: i]
      [Near : {... Unknown ....}]
                   ^
      [Line: 1, Column: 0]
      return true;
      

      Example :

      ParserContext ctx = new ParserContext();
      ctx.setStrongTyping(true);
      ctx.setStrictTypeEnforcement(true);
      		
      String script = "for(int i=0;i<2;i++) { " +
      "  System.out.println(i+\"\");" +
      "} " +
      " return true;";
      
      try {
       CompiledExpression compiled = (CompiledExpression)MVEL.compileExpression(script, ctx);
       HashMap<String, Object> map = new HashMap<String, Object>();
       new MVELScript(compiled).execute(map);
      } catch(Exception e) {
       e.printStackTrace();
      }
      

        Activity

        Hide
        Mike Brock added a comment -

        fixed in latest commit.

        Show
        Mike Brock added a comment - fixed in latest commit.

          People

          • Assignee:
            Mike Brock
            Reporter:
            Nicolas Laplante
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: