Repro ocaml code:
class type _y = object
method height : int [@@bs.set {no_get}]
(* [height] is setter only *)
end [@bs]
No attributes when converted. Related: #693
How to attack this problem for first time contributor:
class type _y = object
method height : int [@@bs.set {no_get}]
end [@bs]
refmt -parse ml -print re try.ml, notice that the [@bs] attributes are disappeared from the output.You job is to change "reason_pprint_ast.ml" so the conversion preserves the attributes.
Hi! I would like to claim this issue :)
I have started investigating, and found the old closed PR that fixes this. However this causes indentation issues.
I printed the intermediate easy-format representation and found there because of the fix, there is a attach_std_attrs call that wraps it in another list. I have yet to figure out how to fix this, but would like to jot down my findings here. Thanks!
This is the fixed output:
List: open close sep break Force_breaks_rec
List: open close sep break Force_breaks_rec
Atom:''
Label (break = Auto):
left
List: open close sep break No_breaks
Label (break = Auto):
left
Atom:'class type'
right
Atom:'_y'
Atom:'='
right
List: open close sep break No_breaks <<< here is the extra enclosing List
List: open { close } sep break Force_breaks_rec
Label (break = Auto):
left
Label (break = Auto):
left
Atom:'pub'
right
List: open close sep break Never_wrap
Atom:'height:'
right
List: open close sep break No_breaks
Atom:'int'
List: open close sep break Never_wrap
List: open close sep break No_breaks
Atom:'[@bs]'
Atom:';'
This is the original output
List: open close sep break Force_breaks_rec [2/69]
List: open close sep break Force_breaks_rec
Atom:''
Label (break = Auto):
left
List: open close sep break No_breaks
Label (break = Auto):
left
Atom:'class type'
right
Atom:'_y'
Atom:'='
right
List: open { close }; sep break Force_breaks_rec
Label (break = Auto):
left
Label (break = Auto):
left
Atom:'pub'
right
List: open close sep break Never_wrap
Atom:'height:'
right
List: open close sep break No_breaks
Atom:'int'
Thank you, @ngzhian.
Most helpful comment
How to attack this problem for first time contributor:
refmt -parse ml -print re try.ml, notice that the [@bs] attributes are disappeared from the output.You job is to change "reason_pprint_ast.ml" so the conversion preserves the attributes.