Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix to List.CartesianProduct node #9431

Merged

Conversation

aparajit-pratap
Copy link
Contributor

@aparajit-pratap aparajit-pratap commented Jan 16, 2019

Purpose

Fixes regression caused by #9388 in List.CartesianProduct and adds missing test.

As a result of #9388 for loop behavior had changed. As a result of making Get.ValueAtIndex disallow array promotion of its list argument, for loops inside imperative language blocks no longer iterated over a single value. Previously the single value was getting promoted to an array before the for loop could iterate over it. This is because the for loop expression is first compiled to AST's as shown in this example:

                x = 0;
                a = [10, 20, 30, 40]
                for(val in a)
                {
                    x = x + val;
                }

                Compiles down to:

                x = 0;
                a = [10, 20, 30, 40];
                val = null;
                %forloop_key = a.key;
                %forloop_expr = a;

                while( %forloop_key != null)
                {
                    val = Get.ValueAtIndex(%forloop_expr, %forloop_key); => Array promotion!!!
                    %forloop_key = %forloop_key + 1;
                    x = x + val;
                }

The fix is to add yet another ValueAtIndex like ZT method specifically for for loop compilation that does not have the AllowArrayPromotion(false) attribute.

Declarations

Check these if you believe they are true

  • The code base is in a better state after this PR
  • Is documented according to the standards
  • The level of testing this PR includes is appropriate
  • User facing strings, if any, are extracted into *.resx files
  • All tests pass using the self-service CI.
  • Snapshot of UI changes, if any.
  • Changes to the API follow Semantic Versioning, and are documented in the API Changes document.

Reviewers

@mjkkirschner
@QilongTang

FYIs

@smangarole

@aparajit-pratap
Copy link
Contributor Author

@mjkkirschner I'm not happy with this solution of adding more ValueAtIndex methods just for the for loop but this is the simplest solution I have so far. Are you ok with it and the new method names or can you come up with better method names?

@aparajit-pratap aparajit-pratap merged commit 6b84630 into DynamoDS:RC2.1.0_master Jan 16, 2019
@aparajit-pratap aparajit-pratap deleted the fixApplyNested_2.1 branch January 16, 2019 16:59
aparajit-pratap added a commit to aparajit-pratap/Dynamo that referenced this pull request Jan 16, 2019
* fix to List.CartesianProduct node

* add DYN file for test

* revised fix

* reuse code

* add string overload for ValueAtIndex method for for loops

* add for loop test with single value to array promotion
aparajit-pratap added a commit that referenced this pull request Jan 16, 2019
* fix to List.CartesianProduct node

* add DYN file for test

* revised fix

* reuse code

* add string overload for ValueAtIndex method for for loops

* add for loop test with single value to array promotion
reddyashish added a commit to reddyashish/Dynamo that referenced this pull request May 31, 2019
reddyashish added a commit that referenced this pull request Jun 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants