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

Added optional chaining operator support #93

Open
wants to merge 2 commits into
base: feat/new-ops
Choose a base branch
from

Conversation

Fee0
Copy link

@Fee0 Fee0 commented Mar 28, 2024

for normal indexing, computed indexing and function calls

for normal indexing, computed indexing and function calls
@Fee0
Copy link
Author

Fee0 commented Mar 28, 2024

moved some parsing code to extra functions to avoid duplicated code in case of parsing as optional or without optional operator

@Fee0 Fee0 mentioned this pull request Mar 28, 2024
Copy link
Collaborator

@FreeMasen FreeMasen left a comment

Choose a reason for hiding this comment

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

nice work!

@Fee0
Copy link
Author

Fee0 commented Apr 4, 2024

found some code that does not parse correctly:

function a(t){
    return 'normal' === t?.123:'fast' === t?.321:t
}

it seems this is a ternary operator + specification of a floating point number without the leading zero, which gets interpreted as the optional chaining operator now.

I wonder if we have to look ahead now for the matching ":" and then decide if its ternary or optional chaining operator.

@FreeMasen
Copy link
Collaborator

Good catch! I think we we might be able to get away with a check that the character after ?. is an ident_start. I can try and play around with that in ress this weekend

@Fee0
Copy link
Author

Fee0 commented Apr 5, 2024

Ah, I thought its actually from my RESSA code.
I gave it a try to fix this: rusty-ecma/RESS#101

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