Closed tahina-pro closed 7 months ago
Hi @tahina-pro, thanks for the setup to reproduce the issue. I pushed a fix in main
to eta expand op_Bang
... this should unblock you.
Yes, your fix works well, cf. https://github.com/FStarLang/pulse/actions/runs/8239395914 Thank you Aseem!
Context: I am trying to extract DPE to C via krml and I am hitting some ML extraction roadblocks: some ML code extracted from Pulse fails to trigger the expected Karamel extraction rules.
On branch taramana_pulse_krml_20240308, I added two Karamel extraction tests:
A failing extraction test
I have a failing extraction test trying to extract
Pulse.Lib.Reference.replace
(this function would extract to a Rust primitive, but has no C primitive equivalent, so I need to extract its implementationPulse.Lib.Reference.replace'
to C and let Karamel monomorphize it.)When running
make -C share/pulse/examples -f Example.KrmlExtractionTest.Failure.Makefile
, a.krml
file is produced, but then Karamel tries to extract the implementation ofPulse.Lib.Reference,op_Bang
, and of course fails. This means that the corresponding rule forop_Bang
insrc/extraction/ExtractPulse.fst
is not triggered.I instrumented
ExtractPulse.fst
to print all ML expressions before they are extracted to Krml. I found out that, when trying to extractPulse.Lib.Reference.replace'
, Pulse extraction produced the following ML expression (after flattening):(excerpt from the output of this command:
make -C share/pulse/examples -f Example.KrmlExtractionTest.Failure.Makefile _output/Example.KrmlExtractionTest.Failure/Pulse_Lib_Reference.krml
)Notice that there is a spurious
Unit
betweenop_Bang
and its non-ghost argumentr
. I don't know where this spuriousUnit
comes from, but because of it, the ML-to-krml extraction rules forop_Bang
do not trigger.A successful extraction test
By contrast, I also have a successful extraction test where I copy and paste the implementation of
Pulse.Lib.Reference.replace'
and call that copy. Curiously, ML extraction adds no spurious()
there, and so Krml extraction rule forop_Bang
successfully triggers, and Karamel successfully produces a meaningful C file inshare/pulse/examples/_output/Example.KrmlExtractionTest.Success
Can anyone please help me? Thanks in advance!