Uploaded image for project: 'Lucee Development'
  1. LDEV-273

Unexpected scope lookup with VARIABLES and ARGUMENTS name conflict


    • Type: Bug
    • Status: Deployed
    • Priority: New
    • Resolution: Fixed
    • Affects Version/s:
    • Fix Version/s:
    • Labels:
    • Sprint:


      The situation is that I have a function in a script block, and the function has an argument with the same name as a variable in the outer variables scope. In my function code, I reference the argument but, when I call it, I passed in no value.

      I think the code should have thrown an error, telling me that the argument I'm obviously referenced hasn't been defined. Lucee instead looked up into the variables scope and found the variable there. I feel like this is unexpected behavior as it's obvious that my code meant to reference the arguments scope.

      There is no issue if I pass a value to the function. There is also no issue if I define a default value or require the argument. It's only in this example, which is a logic error, that I see the unexpected behavior.

      Unable to find source-code formatter for language: cfml. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
          msg = 'Hello';
          function exclaim( msg ) {
              var exclamation = msg & '!';
              dump( exclamation );
          function exclaim2( msg = '' ) {
              var exclamation = msg & '!';
              dump( exclamation );
          exclaim();          // Should error, but shows 'Hello!'
          exclaim('Goodbye'); // Shows 'Goodbye!'
          exclaim2();         // Shows '!'

      I see this same behavior in Lucee running as CFML dialect and Lucee dialect. I did my testing in the Lucee dialect.




            • Assignee:
              michaeloffner Michael Offner
              awayken Miles Rausch
            • Votes:
              1 Vote for this issue
              3 Start watching this issue


              • Created: