Skip to content

Conversation

@Yi2255
Copy link
Contributor

@Yi2255 Yi2255 commented Nov 14, 2024

Add some feature about nullish coalescing operator and assignment

Copy link
Collaborator

@saelo saelo left a comment

Choose a reason for hiding this comment

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

Thanks!
It would be nice to also add support in the compiler for this. See #461 or similar PRs for examples. But also fine to land like this and maybe leave a TODO or file an issue :)

return self.rawValue
}

static public func allCaseWithoutNCO() -> Array<BinaryOperator> {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the idea behind this? Why is the new operator special?

case .BitwiseXor:
try translateBinaryOperation(.Xor)
case .NCO:
try translateBinaryOperation(.NCO)
Copy link
Collaborator

Choose a reason for hiding this comment

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

You will also need to update the corresponding JavaScript code, see here:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks very much. I missed something here.

case Exp = "**"
case UnRShift = ">>>"
// Nullish coalescing operator (??)
case NCO = "??"
Copy link
Collaborator

Choose a reason for hiding this comment

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

'NCO' is maybe a little weird because none of the other operators have "operator" in their name. 'NC' is maybe a bit short/unintuitive though, so how about just calling it NullCoalesce?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good point. Thanks!

@saelo
Copy link
Collaborator

saelo commented Nov 26, 2024

I guess this can be closed now after #471? If not, please reopen

@saelo saelo closed this Nov 26, 2024
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