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

Cannot use as on anything unioned with a pointer type #13000

Closed
icy-arctic-fox opened this issue Jan 24, 2023 · 2 comments
Closed

Cannot use as on anything unioned with a pointer type #13000

icy-arctic-fox opened this issue Jan 24, 2023 · 2 comments

Comments

@icy-arctic-fox
Copy link
Contributor

The as method can't be used on a union when one of the types is a pointer.

The following doesn't compile:

a = Pointer(UInt8).new(1) || 2
p! typeof(a), a
b = a.as(Pointer(UInt8))
p! typeof(b), b

Gives the error:

 3 | b = a.as(Pointer(UInt8))
         ^
Error: can't cast (Int32 | Pointer(UInt8)) to Pointer(UInt8)

Crystal 1.7.2

@Blacksmoke16
Copy link
Member

Related to/duplicate of #9281?

@beta-ziliani
Copy link
Member

Definitively a duplicate

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants