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

Error when casting mut to const pointer #1059

Open
maximebuyse opened this issue Oct 28, 2024 · 2 comments
Open

Error when casting mut to const pointer #1059

maximebuyse opened this issue Oct 28, 2024 · 2 comments
Labels
bug Something isn't working engine Issue in the engine

Comments

@maximebuyse
Copy link
Contributor

use std::ptr::NonNull;


pub fn g(x: * const i32) -> i32 {
    1
}


unsafe fn f(x: NonNull<i32>) -> i32 {
    g(x.as_ptr())
}

Open this code snippet in the playground

This gives:

error: [HAX0002] (AST import) Fatal error: something we considered as impossible occurred! Please report this by submitting an issue on GitHub!
Details: Pointer, with [cast] being Types.MutToConstPointer
  --> src/lib.rs:10:7
   |
10 |     g(x.as_ptr())

and

error: [HAX0002] (RefMut) Fatal error: something we considered as impossible occurred! Please report this by submitting an issue on GitHub!
Details: expected an arrow type here
  --> src/lib.rs:10:1
   |
10 |     g(x.as_ptr())

I also found the same kind of error with Details: Pointer, with [cast] being Types.UnsafeFnPointer

@maximebuyse maximebuyse added bug Something isn't working engine Issue in the engine labels Oct 28, 2024
@W95Psp
Copy link
Collaborator

W95Psp commented Oct 28, 2024

Thanks, that's the engine side of #1057 I believe!

@Nadrieril
Copy link
Collaborator

There are no constants involved here though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working engine Issue in the engine
Projects
None yet
Development

No branches or pull requests

3 participants