Comments (4)
Thanks for the report. Indeed there seems to be a miscompilation in this case. The lambda
code of the "dps" (destination-passing style) transform of the function in your example is
test_1_dps/280
(function dst/287 offset/286[int] param/285 tail_mod_cons
(if param/285
(let (tl/288 =a (field 1 param/285))
(try
(makeblock 0 (int,*) (caml_int_of_string (field 0 param/285))
(apply test_1/269 tl/288 tailcall(false)))
with exn/289
(if (== (field 0 exn/289) (field 6 (global Stdlib!)))
(let (block/290 = (makemutable 0 (int,*) -1 24029))
(seq
(setfield_ptr(heap-init)_computed dst/287 offset/286
block/290)
(apply test_1_dps/280 block/290 1 tl/288 tailcall)))
(setfield_ptr(heap-init)_computed dst/287 offset/286
(reraise exn/289)))))
(setfield_ptr(heap-init)_computed dst/287 offset/286 0))))
The problem is that in the body of the try-with
, the code does not "fill" the destination dst/287
, so the block is left filled with garbage.
A tentative fix is in #12958
from ocaml.
This is indeed a bug! The following patch fixes it, but I need to understand it better and audit the rest of the transformation for similar issues.
diff --git i/lambda/tmc.ml w/lambda/tmc.ml
index 5edbcdf8b5..a9bc1d1baa 100644
--- i/lambda/tmc.ml
+++ w/lambda/tmc.ml
@@ -644,8 +644,8 @@ let rec choice ctx t =
not in tail-call position (after it returns
we need to remove the exception handler),
so it is not transformed here *)
- let l1 = traverse ctx l1 in
- let+ l2 = choice ctx ~tail l2 in
+ let+ l1 = Choice.lambda (traverse ctx l1)
+ and+ l2 = choice ctx ~tail l2 in
Ltrywith (l1, id, l2)
| Lstaticcatch (l1, ids, l2) ->
(* In [static-catch l1 with ids -> l2],
from ocaml.
@SylvainBoilard this should now be fixed (in development versions). Thanks again for the report!
from ocaml.
Thank you for the quick fix, looking forward for the next release!
from ocaml.
Related Issues (20)
- add more modules to `StdLabels` / `MoreLabels` HOT 4
- Tail call optimisation not explicitely guaranteed by the manual HOT 1
- A minor oversight in pretty-printing raw identifiers (for new types in Pexp_function) HOT 4
- `value_kind` classification for `function` cases only looks at first case HOT 2
- Ground coercion is not composable HOT 1
- Regression with default GC settings between `4.14.2` and `5.1.1` HOT 7
- Doc typo in `Printexc` HOT 2
- Abnormal exit after upgrading to OCaml 5 HOT 4
- Restore native armv7 support for NetBSD 10.0 HOT 7
- Missing warning when an attribute is ignored or makes no sense HOT 9
- Support parameter constraints in module signature type equalities HOT 5
- Update the effect handlers manual page to use syntax HOT 3
- Simplify effect handler closure and reperform by dropping the `last_fiber` argument
- Module type substitutions in signature of recursive modules are not checked for cyclicity
- Sub-module identities inside an applicative functor are actually generative, leading to invalid signatures
- Strange error message with trunk HOT 5
- "β t is less general than ∀α. α t" with trunk HOT 14
- Please provide guidance whether the static linking exception applies to distributions like DkML HOT 12
- Semantics of toplevel let-bindings in classes HOT 11
- Make extensible variants more efficient and mashalable. HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ocaml.