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 return Procs from top-level funs #14691

Open
HertzDevil opened this issue Jun 11, 2024 · 0 comments
Open

Cannot return Procs from top-level funs #14691

HertzDevil opened this issue Jun 11, 2024 · 0 comments

Comments

@HertzDevil
Copy link
Contributor

The following:

fun foo : -> Int32
  -> { 1 }
end

produces a codegen error:

Module validation failed: Function return type does not match operand type of return inst!
  ret %"->" %3, !dbg !664
 ptr

This happens even when using a ProcPointer:

fun foo : LibC::Char* -> LibC::SizeT
  ->LibC.strlen
end

It looks like the fun is trying to return a Crystal Proc that contains an additional closure data pointer; instead, it should reject any closures and return just the function pointer using ~check_proc_is_not_closure, similar to when a Proc is passed as a lib call argument.

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

1 participant