effekt icon indicating copy to clipboard operation
effekt copied to clipboard

Disallow block parameters on extern forever

Open marvinborner opened this issue 2 weeks ago • 4 comments

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

marvinborner avatar Dec 11 '25 17:12 marvinborner

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

b-studios avatar Dec 11 '25 18:12 b-studios

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

  • https://github.com/effekt-lang/effekt/pull/1020/files#diff-95b6afb9b993424af9c118c39adf1b71ab6cc1f4dd061358b4a19659e450a99aR575 uses this for the isJSNode etc functions.

That is why I fixed the captures for them in https://github.com/effekt-lang/effekt/issues/448 . This does work on LLVM, because they are compiled away before reaching machine.

marzipankaiser avatar Dec 12 '25 10:12 marzipankaiser

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?

marzipankaiser avatar Dec 12 '25 10:12 marzipankaiser

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

phischu avatar Dec 13 '25 19:12 phischu

@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).

marzipankaiser avatar Dec 16 '25 13:12 marzipankaiser