tracker issue : CF-4202341

select a category, or use search below
(searches all categories and all time range)
Title:

[ANeff] Bug for: var is sometimes ignored (Lucee correct)

| View in Tracker

Status/Resolution/Reason: To Fix//BugVerified

Reporter/Name(from Bugbase): Aaron Neff / ()

Created: 05/09/2018

Components: Language, Scopes

Versions: 2016,11.0,2018

Failure Type: Incorrectly functioning

Found In Build/Fixed In Build: 2018.0.01.308605 (PreRelease) /

Priority/Frequency: Normal / Very few users will encounter

Locale/System: / Platforms All

Vote Count: 0

Issue: var is sometimes ignored (Lucee correct)

Repro:

<cfscript>
  application.delete("foo");
  session.delete("foo");
  function f() {
    //Begin CF workaround
    /*var application={};
    var session={};
    var request={};
    var form={};
    var url={};
    var variables={};*/
    //End CF workaround
    var application.foo = "bar";
    var session.foo = "bar";
    var request.foo = "bar";
    var form.foo = "bar";
    var url.foo = "bar";
    var variables.foo = "bar";
    return local;
  }
  writeDump(var=f(), label="f()");
  writeDump(var=application, label="application");
  writeDump(var=session, label="session");
  writeDump(var=request, label="request");
  writeDump(var=form, label="form");
  writeDump(var=url, label="url");
  writeDump(var=variables, label="variables");
</cfscript>

Actual Result: In CF, local scope contains none of the `var`d variables (bad). In Lucee, `var` always means local scope, so the local scope contains all of the `var`d variables (good).

Expected Result: In CF and Lucee, local scope contains all of the `var`d variables.

Workaround: Uncomment the "Begin/End CF workaround" section.

Suggestion: Since `var` must always mean local-scope, any existing code using `var` to create a non-local-scope variable is broken. Therefore, backward-compat must not be maintained. Lucee has the correct behavior here.

Attachments:

Comments:

Lucee example: https://trycf.com/gist/bd7adfc0a15010d1ceda60139c3aa279/lucee5?theme=monokai ColdFusion example: https://cffiddle.org/app/f0109d3f-0fb7-4d22-ae88-41d06bef670f
Comment by Aaron N.
27721 | May 09, 2018 03:56:34 AM GMT
Fixing this means CF-4202194 cannot be 'fixed', as explained in my 05/09/2018 04:55:05 GMT comment on that ticket.
Comment by Aaron N.
27722 | May 09, 2018 04:59:15 AM GMT
Hi Adobe, I see this ticket is "To Fix". Yet CF-4202194 is also "To Fix". It is not possible to fix both, as their fixes would collide. Of course my vote is for CF-4202341 to be fixed. B/c 'var' must always mean local-scope. Additionally, my vote is for CF-4202194 to not be fixed. B/c code using 'final' should not write variables to a different scope based on if the code is used within or outside of a UDF. Thanks!, -Aaron
Comment by Aaron N.
27730 | May 10, 2018 01:02:19 AM GMT
Oh, I forgot to mention: Special credit to Sean Corfield. Thanks!, -Aaron
Comment by Aaron N.
27775 | May 13, 2018 07:30:42 AM GMT