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

Range type swallowed in type union #10027

Open
arnetheduck opened this issue Dec 17, 2018 · 2 comments · May be fixed by #24250
Open

Range type swallowed in type union #10027

arnetheduck opened this issue Dec 17, 2018 · 2 comments · May be fixed by #24250

Comments

@arnetheduck
Copy link
Contributor

import typetraits

type Uint24* = range[0'u32 .. 0xFFFFFF'u32]

proc a(v: SomeInteger|Uint24) = echo type(v)

a(42)
a(42.Uint24)
[arnetheduck@tempus tmp]$ nim c -r test.nim 
...
Hint: /home/arnetheduck/tmp/test  [Exec]
int
uint32

[arnetheduck@tempus tmp]$ nim --version
Nim Compiler Version 0.19.0 [Linux: amd64]
Compiled at 2018-09-26
Copyright (c) 2006-2018 by Andreas Rumpf

git hash: f6c5c636bb1a1f4e1301ae0ba5a8afecef439132
active boot switches: -d:release

as an aside, the following works:

import typetraits

type Uint24* = range[0'u32 .. 0xFFFFFF'u32]

proc a(v: SomeInteger) = echo type(v)
proc a(v: Uint24) = echo type(v)

a(42)
a(42.Uint24)

and prints the expected

int
Uint24
@LemonBoy
Copy link
Contributor

Back in 2014 @zah decided to add a skipTypes({tyRange}) in sigmatch's bindingRet, that's why the tyOr is resolved to the range base type.

@stale
Copy link

stale bot commented Aug 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Aug 4, 2020
@metagn metagn removed the stale Staled PR/issues; remove the label after fixing them label Sep 18, 2024
metagn added a commit to metagn/Nim that referenced this issue Oct 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants