E2E Bridge E2E Commerce

Compiler Behavior Change Concerning Local Variable Redeclaration

E2E Forum News Compiler Behavior Change Concerning Local Variable Redeclaration

Viewing 1 post (of 1 total)
  • Author
  • #3189


    Assume, you have an Action Script like this:

    local myVar = ''
    local myVar = myObject.stringAttribute if myObject.stringAttribute.exists();

    Local varable myVar is a String variable that is declared twice in the Action Script. It is initialized with “empty string”. In a second step, this initial value is overwritten by a string attribute, if existing.

    Compiler behavior in BUILDER versions before 6.0.28

    myVar contains an empty string.
    The initial value of myValue is preserved, if the condition of the second statement evaluates to false.

    Compiler behavior in BUILDER versions as of 6.0.28

    myVar is NULL.
    If the condition of the second statement evaluates to false, contents of myVar are set to NULL.

    Reason for this is that we now transform local a = b if c; to local a = condition(c, b, null);. The old behavior caused problems with wrong variable initialization in iterations.

    Using BUILDER 6.0.28 may have severe consequences, as affected variables may become NULL. This can have unexpected side effects that only are revealed at runtime and are hard to find.


    Re-declaring a local variable is no good practice. In case the Compiler points you to a implementation like this, you should replace the second (or more) [create] local statements by a set statement:

    local myVar = '';
    set myVar = myObject.stringAttribute if myObject.stringAttribute.exists();

    If you have BUILDER 6.0.28 installed, we strongly recommend to update to BUILDER Only this BUILDER version will point you to the critical statements.
    To be sure to find all of them, perform a Clean all on your BUILDER project (see Menu Overview of the E2E Model Compiler).

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.