You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Original bug ID: 4328 Reporter: cstork Assigned to: ertai Status: closed (set by @xavierleroy on 2010-04-29T12:26:12Z) Resolution: fixed Priority: normal Severity: minor Version: 3.10.0 Fixed in version: 3.10+dev Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues Monitored by: cstork
Bug description
If I try to pretty print
<:str_item< type $t$; ... >>
where t could potentially be a nil node, ie, <:ctyp<>>, then camlp4r produces a stack overflow.
Two suggestions:
CleanAst.ml could easily turn such empty str_item nodes into <:str_item<>>. Attached is a simple patch that achieves this for this case. If there's interest I'd extend this patch to cover more useful cases. This has the potential to make writing camlp4 extensions more pleasant.
camlp4 shouldn't simply crash on nil nodes, but produce a meaningful error message. In case that such a nil node is not pretty printed but dump'ed the error message is
Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml",
line 792, char 11
Original bug ID: 4328
Reporter: cstork
Assigned to: ertai
Status: closed (set by @xavierleroy on 2010-04-29T12:26:12Z)
Resolution: fixed
Priority: normal
Severity: minor
Version: 3.10.0
Fixed in version: 3.10+dev
Category: -for Camlp4 use https://github.com/ocaml/camlp4/issues
Monitored by: cstork
Bug description
If I try to pretty print
<:str_item< type$t$ ; ... >>
where t could potentially be a nil node, ie, <:ctyp<>>, then camlp4r produces a stack overflow.
Two suggestions:
CleanAst.ml could easily turn such empty str_item nodes into <:str_item<>>. Attached is a simple patch that achieves this for this case. If there's interest I'd extend this patch to cover more useful cases. This has the potential to make writing camlp4 extensions more pleasant.
camlp4 shouldn't simply crash on nil nodes, but produce a meaningful error message. In case that such a nil node is not pretty printed but dump'ed the error message is
Assertion failed, file "camlp4/Camlp4/Struct/Camlp4Ast2OCamlAst.ml",
line 792, char 11
which is a bit more helpful.
Additional information
To reproduce:
$ echo << DONE
open Camlp4.PreCast.Syntax;
EXTEND Gram
GLOBAL: str_item;
str_item: [[ "type_Nil" -> <:str_item< type $ <:ctyp<>> $ >> ]];
END;
DONE > pa_type_Nil.ml
$ ocamlc -c -pp camlp4rf -I +camlp4 pa_type_Nil.ml
$ echo "type_Nil;" > type_Nil.ml
$ camlp4r pa_type_Nil.cmo type_Nil.ml
type (((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((((...
Camlp4: Uncaught exception: Stack_overflow
File attachments
The text was updated successfully, but these errors were encountered: