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

fix: Fix "legacy" enums breaking Swift compiler #346

Merged
merged 5 commits into from
Nov 19, 2024
Merged

Conversation

mrousavy
Copy link
Owner

@mrousavy mrousavy commented Nov 18, 2024

Previously, we only tested a string enum (discriminating union):

type Powertrain = 'gas' | 'electric'

Now, we also test an "old" enum, aka an enum backed by a number:

enum Powertrain { GAS, ELECTRIC }

This is a slightly different implementation on the native side, since we now use the number as a value of truth.

On iOS, for some reason this breaks when using std::optional<Enum>.

This code breaks:

      self.__implementation.optionalOldEnum = newValue.value

This code works:

      self.__implementation.optionalOldEnum = newValue.has_value() ? newValue.pointee : nil

So this PR fixes this. And adds a test.

Copy link

vercel bot commented Nov 18, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
nitro-docs ⬜️ Skipped (Inspect) Nov 19, 2024 0:20am

@mrousavy mrousavy changed the title feat: Add OldEnum tests (enum with numbers) fix: Fix "legacy" enums breaking Swift compiler Nov 19, 2024
@mrousavy mrousavy merged commit cb9cf99 into main Nov 19, 2024
14 checks passed
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.

1 participant