Skip to content

Conversation

@sam-goodwin
Copy link
Owner

@sam-goodwin sam-goodwin commented Aug 2, 2022

Partial #374

  • remove flattening logic from compile.ts
function foo() {
  $AWS.DynamoDB.GetItem(..)

  // before:
  CallExpr(ReferenceExpr(() => $AWS.DynamoDB.GetItem), ..)

  // now:
  CallExpr(PropAccessExpr(GetItem, PropAccessExpr(DynamoDB, ReferenceExpr(() => $AWS)))
}
  • update interpreters to resolve FucntionlessAST to ReferenceExpr as we can no longer rely on that work being done during tsc.

@sam-goodwin sam-goodwin requested a review from thantos August 2, 2022 07:46
@netlify
Copy link

netlify bot commented Aug 2, 2022

Deploy Preview for effortless-malabi-1c3e77 ready!

Name Link
🔨 Latest commit 92ddb3d
🔍 Latest deploy log https://app.netlify.com/sites/effortless-malabi-1c3e77/deploys/62ead6de04355e00091898e4
😎 Deploy Preview https://deploy-preview-376--effortless-malabi-1c3e77.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@sam-goodwin sam-goodwin marked this pull request as ready for review August 3, 2022 02:58
Comment on lines +402 to +407
if (node === undefined) {
if (defaultValue === undefined) {
return [];
} else {
return resolve(defaultValue, undefined);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong? Default value can only be determined at runtime.

const { a = func } = b ? { a: func2 } : { a: undefined }

a is func if b is falsey (runtime) or func2 is undefined (maybe runtime)

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We care calling resolve on the defaultValue which can return 0, 1 or many possible values. In your case, we would have logic for the ConditionExpr that returns [{a: func2}, {a: undefined}] which then distributes to [func2, undefined] which then unions with a = func to create [func, func2, undefined] as the set of all possible values that a can be.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's expand on this in #310 ?

Comment on lines 413 to 416
return resolve(node.parent, node.initializer).flatMap((pattern) => {
if (isIdentifier(node.name)) {
return [pattern[node.name.name]];
} else {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is pattern here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad name - it's one of the possible values that node.initializer can be

Comment on lines +367 to +370
* for (const a of tables) {
* const b = a;
* // ^ [table1, table2]
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this implemented? I don't see any code that could return an array of more than 1

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not yet, no. I implemented only the cases I needed for the tests to pass - incremental progress. I added the comments as I was thinking it through.

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We would need to update the interpreter logic to support this case so it didn't matter.

@sam-goodwin sam-goodwin merged commit 1b6149a into main Aug 3, 2022
@sam-goodwin sam-goodwin deleted the remove-reference-flattening branch August 3, 2022 20:29
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.

3 participants