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

[request] Allow enum overloads, without unnecesarily adding enumval to their names #95

Open
heysokam opened this issue Mar 18, 2024 · 3 comments

Comments

@heysokam
Copy link

heysokam commented Mar 18, 2024

Quote from discord:

Basically this line has to be done without the global state:
https://github.com/PMunch/futhark/blob/master/src/futhark.nim#L349
Since usedNames is passed in (through state, but there is an overload here) it should be fairly simple to create a new one for each enum and just use sanitizeName with that

@PMunch
Copy link
Owner

PMunch commented Mar 21, 2024

Tried to implement this but Nim wasn't happy with the redefinition either.. Could you make a test case showcasing what you wanted?

@heysokam
Copy link
Author

heysokam commented Mar 22, 2024

Tried to implement this but Nim wasn't happy with the redefinition either.. Could you make a test case showcasing what you wanted?

You are right. I just tested without a {.pure.} enum and nim is not happy :(
I guess I only tried this with pure before? I thought enum fields didn't collide with any other symbol 🤔

type Thing *{.pure.}= enum
  One, Two

type One * = object
  val *:int

echo One(val: 1)
echo $One

This works, but apparently it doesn't without pure

@PMunch
Copy link
Owner

PMunch commented Mar 22, 2024

Hmm, I have to read up on what pure does. It used to be a lot stricter, but if it's relaxed enough now I'd be open to marking all enums as pure. Another difficulty wa that the when declared checks tripped up. So I'll need to refine those in a way which makes them only fire if it would trigger a collision.

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

No branches or pull requests

2 participants