anoma / juvix

A language for intent-centric and declarative decentralised applications
https://docs.juvix.org
GNU General Public License v3.0
457 stars 53 forks source link

Reg->C: ALLOC_CONSTR_TUPLE calls are generated with the incorrect number of arguments #2588

Open paulcadman opened 10 months ago

paulcadman commented 10 months ago

We wish to use the MemRepTuple constructor representation in the Nockma backend.

However the code emitted by the Reg->C translation is incorrect:

https://github.com/anoma/juvix/blob/1147e1fce131f5b423fd558e5636e6aaf23120ac/src/Juvix/Compiler/Backend/C/Translation/FromReg.hs#L341-L342

Specifically an ALLOC_CONSTR_TUPLE call is generated with too many arguments.

/private/var/folders/z5/h_kmf4q1139f0gqhj1_hqd4w0000gn/T/tmp-b0a3b6f6c4b6a816/test055.c:56:48: error: too many arguments provided to function-like macro invocation
   56 |         ALLOC_CONSTR_TUPLE(juvix_temp_var, 11, 2);
lukaszcz commented 10 months ago

In general, only MemRepConstr is supported in C code generation. There are macros/functions in the C runtime that enable support for other representations, but they have not been tested and code generation with them has not been fully implemented.

To support MemRepTuple one needs to look at and modify C code generation for: