-
Notifications
You must be signed in to change notification settings - Fork 412
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #779 from diml/fix-sexp-record-bug
Fix sexp record bug
- Loading branch information
Showing
4 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
(* -*- tuareg -*- *) | ||
open Stdune;; | ||
open Sexp.Of_sexp;; | ||
|
||
let pp_sexp_ast ppf sexp = | ||
Sexp.pp ppf (Sexp.Ast.remove_locs sexp) | ||
;; | ||
#install_printer pp_sexp_ast;; | ||
[%%expect{| | ||
val pp_sexp_ast : Format.formatter -> Stdune.Sexp.Ast.t -> unit = <fun> | ||
|}] | ||
|
||
Printexc.record_backtrace false;; | ||
[%%expect{| | ||
- : unit = () | ||
|}] | ||
|
||
let sexp = Sexp.parse_string ~fname:"" ~mode:Single {| | ||
((foo 1) | ||
(foo 2)) | ||
|} | ||
[%%expect{| | ||
val sexp : Usexp.Ast.t = ((foo 1) (foo 2)) | ||
|}] | ||
|
||
let of_sexp = record (field "foo" int) | ||
let x = of_sexp sexp | ||
[%%expect{| | ||
val of_sexp : int Stdune.Sexp.Of_sexp.t = <fun> | ||
Exception: | ||
Stdune__Sexp.Of_sexp.Of_sexp (<abstr>, | ||
"Field \"foo\" is present too many times", None). | ||
|}] |