Skip to content

feat(parser): support === and !== operators #1500

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

Conversation

pkozlowski-opensource
Copy link
Member

Closes #1496

@pkozlowski-opensource
Copy link
Member Author

@vicb I was a bit surprised to see that === and !== work "out of the box" in Dart. Is our transpiler smart enough to convert === to identical ? Or does Dart have those operators?

@vicb
Copy link
Contributor

vicb commented Apr 22, 2015

Dart doesn't support ===/!== but Traceur used to transpile those to identical(). It has probably been ported to TS.

@pkozlowski-opensource
Copy link
Member Author

Oh, good - we should be fine then!

@@ -304,7 +304,7 @@ class _Scanner {
assert(this.peek == StringWrapper.charCodeAt(one, 0));
this.advance();
var str:string = one;
if (this.peek == code) {
while (this.peek == code) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Doesn't this only work because by luck '=' = '=' ? (ie should we add three ?)

Copy link
Member Author

Choose a reason for hiding this comment

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

@vicb not sure I got you here. We are getting a right token out of lexer: pkozlowski-opensource@8d58892#diff-97c47bfad039c045846c9d65a42b72f9R161

I'm pushing even more tests :-)

Copy link
Contributor

Choose a reason for hiding this comment

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

I haven't looked at the details but you do str += two multiple times, is that right or does this happen to work because the tokens end with a doubled symbol (2*=) ?

Copy link
Contributor

Choose a reason for hiding this comment

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

and what if ======================

Copy link
Member Author

Choose a reason for hiding this comment

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

It works since both !== and === and with the same two (=) token. And at the end we do verify that what got built is a real operator, see: pkozlowski-opensource@9e5c882#diff-64a5b021a00571a4aa77bbc3c3c08057R311

So I guess there is some kind of back-tracking mechanism (?). But even if there would, I guess it would be less efficient than just introducing 3rd arg. Let me change the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

@vicb actually I think we are fine with the current impl. I was trying to break it with many use cases but can't. For example, if you do ====================== you will just get an invalid operator ====================== with the current impl. If we are more explicit we would get several tokens with the === which would be an invalid expression anyway. So we would just do more work for nothing....

@pkozlowski-opensource
Copy link
Member Author

@vicb I've pushed an update with more tests. I'm still not sure about your comment. Can you think of a test that would show it breaking?

@mhevery mhevery added @lgtm action: merge The PR is ready for merge by the caretaker labels Apr 23, 2015
vicb added a commit to vicb/angular that referenced this pull request May 19, 2015
vicb added a commit to vicb/angular that referenced this pull request May 19, 2015
vicb added a commit to vicb/angular that referenced this pull request May 19, 2015
vicb added a commit to vicb/angular that referenced this pull request May 19, 2015
vicb added a commit to vicb/angular that referenced this pull request May 20, 2015
@pkozlowski-opensource pkozlowski-opensource deleted the strict_equality branch July 20, 2015 12:55
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Question: Property binding with strict equality
5 participants