Open OlivierNicole opened 2 years ago
Similarly (?),
$ cat splices.ml
macro one = << 1 >>
macro two = << 2 >>
macro three = << 3 >>
let () =
begin
Printf.printf "%d\n" $(one);
Printf.printf "%d\n" $(two);
Printf.printf "%d\n" $(three);
end
$ ocaml splices.ml
1
1
1
I see why this is happening. Visibly I made an error when switch the quoting/splicing mechanisms from Parsetre to Lambda quotes.
https://github.com/modular-macros/ocaml-macros/blob/c1d7fc74b7c55515bf9435ae07ffee89384f6689/bytecomp/translcore.ml#L1159-L1165
splice_index
is never updated.
In addition, the contribution of https://github.com/modular-macros/ocaml-macros/commit/42a00617d75290056c2632c6f73b792432584f3d which introduced a sane (i.e. not using mutable state) management of toplevel splices has somehow disappeared.
There seems to be an incorrect shadowing when splicing a fast exponentiation macro. Using the following
power.ml
file:We get the following results in the toplevel at revision https://github.com/modular-macros/ocaml-macros/commit/05372c7248b5a7b1aa507b3c581f710380f17fcd:
The result string should be
"(1,3)"
.This example used to work at the time of this blog post so maybe a bug was introduced when switch from Parsetree to Lambda for the quotes?