Skip to content

Commit

Permalink
Integrate review: bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
ccasin committed Nov 5, 2024
1 parent ec39ea7 commit 001918d
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/Fmt_ast.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1063,7 +1063,7 @@ and fmt_core_type c ?(box = true) ?pro ?(pro_space = true) ?constraint_ctx
(Params.Indent.type_constr c.conf)
( fmt_core_type c (sub_typ ~ctx t1)
$ fmt "@ "
$ fmt_longident_loc c ~constructor:true lid )
$ fmt_longident_loc c ~constructor:false lid )
| Ptyp_constr (lid, t1N) ->
hvbox
(Params.Indent.type_constr c.conf)
Expand Down Expand Up @@ -1276,10 +1276,10 @@ and fmt_pattern ?ext c ?pro ?parens ?(box = false)
match ppat_desc with
| Ppat_any -> str "_"
| Ppat_var {txt; loc} ->
let is_symbol = Std_longident.String_id.is_symbol txt in
let str = if is_symbol then str else ident in
Cmts.fmt c loc
@@ wrap_if
(Std_longident.String_id.is_symbol txt)
"( " " )" (ident txt)
@@ wrap_if is_symbol "( " " )" (str txt)
| Ppat_alias (pat, {txt; loc}) ->
let paren_pat =
match pat.ppat_desc with
Expand Down Expand Up @@ -1368,7 +1368,7 @@ and fmt_pattern ?ext c ?pro ?parens ?(box = false)
| names ->
hvbox 0
(Params.parens c.conf
(str "type " $ list names "@ " (fmt_str_loc c)) )
(str "type " $ list names "@ " (fmt_ident_loc c)) )
$ fmt "@ " )
$ fmt_pattern c (sub_pat ~ctx pat) ) )
| Ppat_variant (lbl, None) -> variant_var c lbl
Expand Down
2 changes: 1 addition & 1 deletion test/passing/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -10021,7 +10021,7 @@
(rule
(alias runtest)
(package ocamlformat)
(action (diff tests/raw_identifiers.ml raw_identifiers.ml.stdout)))
(action (diff tests/raw_identifiers.ml.ref raw_identifiers.ml.stdout)))

(rule
(alias runtest)
Expand Down
18 changes: 18 additions & 0 deletions test/passing/tests/raw_identifiers.ml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ module M = struct
end
end

type 'a \#for = 'a list

type 'a \#sig = 'a \#for

type \#true = bool

let f \#false = \#false

type t = {x: int @@ \#let}

let x @ \#let = 42
Expand All @@ -74,3 +82,13 @@ let x = (~\#let:42, ~\#and:43)
let ((~\#let, ~\#and) : \#let:int * \#and:int) = x

kind_abbrev_ \#let = \#and

type t = T : 'a list -> t

let g x =
let (T (type \#for) (_ : \#for list)) = x in
()

let ( lsl ) x y = x lsl y

let \#lsl x y = x lsl y
16 changes: 16 additions & 0 deletions test/passing/tests/raw_identifiers.ml.js-ref
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,26 @@ module M = struct
end
end

type 'a \#for = 'a list
type 'a \#sig = 'a \#for
type \#true = bool

let f \#false = \#false

type t = { x : int @@ \#let }

let x @ \#let = 42
let x = ~\#let:42, ~\#and:43
let ((~\#let, ~\#and) : \#let:int * \#and:int) = x

kind_abbrev_ \#let = \#and

type t = T : 'a list -> t

let g x =
let (T (type \#for) (_ : \#for list)) = x in
()
;;

let ( lsl ) x y = x lsl y
let ( lsl ) x y = x lsl y
94 changes: 94 additions & 0 deletions test/passing/tests/raw_identifiers.ml.ref
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
module M : sig
class \#and : object
val mutable \#and : int

method \#and : int
end
end = struct
class \#and =
let \#and = 1 in
object
val mutable \#and = \#and

method \#and = 2
end
end

let obj = new M.\#and

module M : sig
type \#and = int
end = struct
type \#and = string
end

let x = (`\#let `\#and : [`\#let of [`\#and]])

let (`\#let \#rec) = x

let f g ~\#let ?\#and ?(\#for = \#and) () = g ~\#let ?\#and ()

type t = '\#let

type \#mutable = {mutable \#mutable: \#mutable}

let rec \#rec = {\#mutable= \#rec}

type \#and = ..

type \#and += Foo

let x = ( ++ )

let x = \#let

let f ~\#let ?\#and () = 1

module type A = sig
type ('\#let, 'a) \#virtual = '\#let * 'a as '\#mutable

val foo : '\#let 'a. 'a -> '\#let -> unit

type foo = {\#let: int}
end

module M = struct
let ((\#let, foo) as \#val) = (\#mutable, baz)

let _ = fun (type \#let foo) -> 1

let f g ~\#let ?\#and ?(\#for = \#and) () = g ~\#let ?\#and ()

class \#let =
object
inherit \#val \#let as \#mutable
end
end

type 'a \#for = 'a list

type 'a \#sig = 'a \#for

type \#true = bool

let f \#false = \#false

type t = {x: int @@ \#let}

let x @ \#let = 42

let x = (~\#let:42, ~\#and:43)

let ((~\#let, ~\#and) : \#let:int * \#and:int) = x

kind_abbrev_ \#let = \#and

type t = T : 'a list -> t

let g x =
let (T (type \#for) (_ : \#for list)) = x in
()

let ( lsl ) x y = x lsl y

let ( lsl ) x y = x lsl y

0 comments on commit 001918d

Please sign in to comment.