Skip to content

Conversation

@marvinborner
Copy link
Member

Previously there was an error message stating that block parameters are currently not supported, but they most probably never will be (@phischu)

@b-studios
Copy link
Collaborator

We should also change the source and core representation. However, it would be good to do this after merging #1219

@marzipankaiser
Copy link
Contributor

Note that there are specific use cases for external block parameters:

That is why I fixed the captures for them in #448 .
This does work on LLVM, because they are compiled away before reaching machine.

@marzipankaiser
Copy link
Contributor

Otherwise, is there a reason they won't be supported? Apart from having to pass them through?
As in every extern fn, the llvm side would be required to handle the calling convention correctly in any case and it can just be a Neg, no?

def transform(extern: core.Extern)(using BlocksParamsContext, ErrorReporter): Declaration = extern match {
case core.Extern.Def(name, tps, cparams, vparams, bparams, ret, capture, body) =>
if bparams.nonEmpty then ErrorReporter.abort("Foreign functions currently cannot take block arguments.")
if bparams.nonEmpty then ErrorReporter.abort("Foreign functions cannot take block arguments.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that this error message will only show up on LLVM (i.e. machine-based backends), maybe we'd want to specify this in the error message?

@phischu
Copy link
Collaborator

phischu commented Dec 13, 2025

We can also just support it, if you tell me what the semantics should be.

@marzipankaiser
Copy link
Contributor

@phischu I would assume that the block parameters are also passed as parameters (of type %Neg probably?) and the foreign llvm code then would have to make sure to use them correctly (it is ffi after all).
That is, the llvm side is required to use the correct calling convention etc, as already is the case when passed a boxed function.
We might need to allow ${box b} in llvm, or allow ${b} for block variables b for this to be usable in LLVM (I have the latter stashed away somewhere, and think it is reasonable).

@phischu phischu self-assigned this Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants