savi-lang / savi

A fast language for programmers who are passionate about their craft.
BSD 3-Clause "New" or "Revised" License
153 stars 12 forks source link

LLVM IR issue for struct with field initializer expressions #435

Closed mneumann closed 1 year ago

mneumann commented 1 year ago

Compilation Error:

---

LLVM Module validation failed: Call parameter type does not match function signature!
ptr %0
 %MQTT.Message.Connect.FIELDS = type { ptr, i8, ptr, ptr, ptr, ptr }  %3 = call ptr @"MQTT.Message.Connect'ref.protocol_name.15076075891161161758.HYGIENIC"(ptr %0), !dbg !7362
Call parameter type does not match function signature!
ptr %0
 %MQTT.Message.Connect.FIELDS = type { ptr, i8, ptr, ptr, ptr, ptr }  %4 = call 'ref.protocol_level.98749216731456095.HYGIENIC"(ptr %0), !dbg !7362
Call parameter type does not match function signature!
ptr %0
 %MQTT.Message.Connect.FIELDS = type { ptr, i8, ptr, ptr, ptr, ptr }  %5 = call 'ref.connect_flags.4113988925871340155.HYGIENIC"(ptr %0), !dbg !7362
Call parameter type does not match function signature!
ptr %0
 %MQTT.Message.Connect.FIELDS = type { ptr, i8, ptr, ptr, ptr, ptr }  %6 = call 'ref.keep_alive.8045874351309185230.HYGIENIC"(ptr %0), !dbg !7362

- please submit an issue ticket with this failure output and attach the dumped L

example.ll.txt

jemc commented 1 year ago

This is a fairly simple issue with a missing pointer load.

Can you show me the Savi code for MQTT.Message.Connect.new and MQTT.Message.Connect.protocol_name?

Seeing those should help me reproduce and fix the issue.

mneumann commented 1 year ago

It happens when I savi run spec this repo:

https://github.com/mneumann-savi/MQTT

jemc commented 1 year ago

This bug happens when you have a :struct whose :let fields have an initializer expression (e.g. :let foo String: "foo").

It's missing an LLVM load to translate the constructor's pointer to a value type.

While waiting for me to fix this issue, one work-around would be to assign to the field in the constructor's body instead of using a field initializer expression.

However, I should be able to fix this quickly.