Skip to content

Conversation

@suwc
Copy link

@suwc suwc commented Aug 3, 2016

Fix some special cases of 'new.target' reference, e.g.:

  • 'new.target' inside direct eval() in global function throws SyntaxError
  • 'new.target' inside indirect eval() throws SyntaxError
  • 'new.target' inside function evaluates to undefined for function call
  • 'new.target' inside function evaluates to said function for constructor call
  • lambda+eval in global function called in a function (SyntaxError)
  • lambda+eval in a function called by global function (okay)
  • other nested/compounded cases with eval(), arrow functions, and functions

@suwc
Copy link
Author

suwc commented Aug 3, 2016

#1348

@suwc
Copy link
Author

suwc commented Aug 3, 2016

@Microsoft/chakra-es, @farzonl, could you take look pls?

if ((this->m_grfscr & fscrEvalCode) != 0 && (this->m_grfscr & fscrIndirect) == 0)
{
Js::JavascriptFunction * caller = nullptr;
if (Js::JavascriptStackWalker::GetNonLamdaCaller(&caller, m_scriptContext))
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we fix the spelling of this API while we're here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Are we walking the call stack looking for the nearest non-lambda caller here? Or am I misreading the logic?

Copy link
Author

Choose a reason for hiding this comment

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

Lamda => Lambda?
Will do.


In reply to: 73384891 [](ancestors = 73384891)

Copy link
Contributor

Choose a reason for hiding this comment

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

Exactly. Thanks.

-- Paul

From: suwc [mailto:[email protected]]
Sent: Wednesday, August 3, 2016 11:43 AM
To: Microsoft/ChakraCore [email protected]
Cc: Paul Leathers [email protected]; Team mention [email protected]
Subject: Re: [Microsoft/ChakraCore] Special cases of new.target (#1377)

In lib/Parser/Parse.cpphttps://github.com//pull/1377#discussion_r73395674:

 }

-}

  • if ((this->m_grfscr & fscrEvalCode) != 0 && (this->m_grfscr & fscrIndirect) == 0)
  • {
  •    Js::JavascriptFunction * caller = nullptr;
    
  •    if (Js::JavascriptStackWalker::GetNonLamdaCaller(&caller, m_scriptContext))
    

Lamda => Lambda?
Will do.


In reply to: 73384891#1377 (comment)


You are receiving this because you are on a team that was mentioned.
Reply to this email directly, view it on GitHubhttps://github.com//pull/1377/files/f89a104fd72f56eba5a59d03df8279f89162b642#r73395674, or mute the threadhttps://github.com/notifications/unsubscribe-auth/APF8ROruobVPRSzvWs2YSV62ni9DvM2sks5qcOExgaJpZM4Jb24l.

Copy link
Author

Choose a reason for hiding this comment

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

Yes, walking to find the nearest non-lambda caller to see if it's global function (SyntaxError) or else (okay).


In reply to: 73385747 [](ancestors = 73385747)

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. That's not actually what we want. We want to find the JS caller, whatever it is, and if it's a lambda we want to look at the non-lambda function (if any) that encloses it lexically. So consider this case:

let l = () => { eval('new.target'); }
(function() { return l(); })();

And, conversely, this one:

var f = (function() { return () => { eval('new.target') } })();
f();

Copy link
Author

Choose a reason for hiding this comment

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

You are right.


In reply to: 73397883 [](ancestors = 73397883)

Copy link
Author

Choose a reason for hiding this comment

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

Fixed in latest rev.


In reply to: 73398523 [](ancestors = 73398523,73397883)

@suwc suwc self-assigned this Aug 3, 2016
},
/*

// Blocked by 'ReferenceError: '<_lexicalNewTargetSymbol>' is undefined' bug
Copy link
Contributor

Choose a reason for hiding this comment

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

Remove the comment if this isn't blocked anymore

Copy link
Author

Choose a reason for hiding this comment

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

Done. Thanks!


In reply to: 73446652 [](ancestors = 73446652)

@suwc
Copy link
Author

suwc commented Aug 5, 2016

@pleath @boingoing @akroshg @Microsoft/chakra-es
Any other comments/questions?

@suwc suwc force-pushed the build/suwc/buddy branch from 27e5513 to 76716c1 Compare August 5, 2016 17:21
@pleath
Copy link
Contributor

pleath commented Aug 5, 2016

👍

@boingoing
Copy link
Contributor

LGTM

Fix some special cases of 'new.target' reference, e.g.:

- 'new.target' inside direct eval() in global function throws SyntaxError
- 'new.target' inside indirect eval() throws SyntaxError
- 'new.target' inside function evaluates to undefined for function call
- 'new.target' inside function evaluates to said function for constructor call
- lambda+eval in global function called in a function (SyntaxError)
- lambda+eval in a function called by global function (okay)
- other nested/compounded cases with eval(), arrow functions, and functions
@suwc suwc force-pushed the build/suwc/buddy branch from eeb9823 to fc08efb Compare August 8, 2016 05:37
@chakrabot chakrabot merged commit fc08efb into chakra-core:master Aug 8, 2016
chakrabot pushed a commit that referenced this pull request Aug 8, 2016
Merge pull request #1377 from suwc:build/suwc/buddy

Fix some special cases of 'new.target' reference, e.g.:

- 'new.target' inside direct eval() in global function throws SyntaxError
- 'new.target' inside indirect eval() throws SyntaxError
- 'new.target' inside function evaluates to undefined for function call
- 'new.target' inside function evaluates to said function for constructor call
- lambda+eval in global function called in a function (SyntaxError)
- lambda+eval in a function called by global function (okay)
- other nested/compounded cases with eval(), arrow functions, and functions
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.

6 participants