New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A not detected loop -> seg fault #5291
Comments
Comment author: @alainfrisch Even simpler: class a = let _ = new a in object end |
Comment author: @alainfrisch Note: segfault is at execution time. |
Comment author: @alainfrisch Local let-binding in a class declaration are currently executed when the class declaration is evaluated, not when the object is created. I'm tempted to consider it is a design bug that: class c = let () = print_endline "XXX" in object end writes "XXX". With this current semantics, one should indeed restrict references to the class being defined. I.e. in class c = let p = e in .... the class c should not be visible in e. But I'd prefer fixing the semantics of let bindings... |
Comment author: @garrigue This evaluation order is intentional. class c = If you put "let r = ref []" this definition goes through, but something strange If you want side-effects at object creation time, then your class should |
Comment author: @alainfrisch
.. or an initializer So, we want the class to be available as a type, but not as a "value", i.e. we should disallow "new c" and "inherit c" in the body of let-binding, right? |
Comment author: @garrigue Yes, I'm working on it now. |
Comment author: @garrigue Fixed in trunk and 4.00, inside transclass.ml, revisions 12531 and 12532 |
Original bug ID: 5291
Reporter: gio
Assigned to: @garrigue
Status: closed (set by @garrigue on 2012-06-01T04:49:38Z)
Resolution: fixed
Priority: normal
Severity: crash
Fixed in version: 4.00.0+dev
Category: ~DO NOT USE (was: OCaml general)
Monitored by: mehdi @ygrek "Julien Signoles" @Chris00
Bug description
Try this code:
class a = let _ = new b in object end
and b = let _ = new a in object end
and you'll find your daily segfault :)
(I've used OCaml 3.12.0 and the svn trunk version)
The text was updated successfully, but these errors were encountered: