syntax icon indicating copy to clipboard operation
syntax copied to clipboard

Doc comments in type with labelled argument fail to parse

Open TheSpyder opened this issue 3 years ago • 9 comments

Using 10.0.0-beta.3

I have an external in my project that looks like this:

@val external myMethod: (
  /** comment for argument 1 */
  ~firstArg: bool,
  /** comment for argument 2 */
  ~secondArg: bool
) => string = "myMethod"

Playground link

When compiling this with v10, it fails to compile:

  I'm not sure what to parse here when looking at "DocComment  comment for argument 1 ".

I can work around the problem using regular comments or @ocaml.doc annotations.

TheSpyder avatar Jul 20 '22 11:07 TheSpyder

This is correct and reflective of where the parser currently accepts @annotations. See release notes.

cristianoc avatar Jul 20 '22 11:07 cristianoc

A.k.a. known breaking change. The kind, that is. Not the specific example.

cristianoc avatar Jul 20 '22 11:07 cristianoc

There's a long story. Something something the ast does not have locations for labelled argument. Which keeps coming up and creating little issues. But we are not changing the ast just yet.

cristianoc avatar Jul 20 '22 11:07 cristianoc

sorry, I have looked at the notes and it wasn't clear (they've become a bit hard to read with breaking changes spread across multiple alpha/beta versions).

I found the note that talks about them only being valid where @foo is allowed, which is confusing because @ocaml.doc works?

TheSpyder avatar Jul 20 '22 11:07 TheSpyder

It's definitely true that we need to improve release notes for the actual release. Would you have a suggestion for how this could have been clarified? Feel free to open a PR on the CHANGELOG directly.

cristianoc avatar Jul 20 '22 11:07 cristianoc

I think, as we get closer to release, it's time to just combine them all into one v10 section. New beta releases can have their own section, but all previous v10 updates should be combined IMO.

I don't think I'll have time to log a PR today, maybe tomorrow. Should I do it against master or the new v10 branch/PR?

TheSpyder avatar Jul 20 '22 11:07 TheSpyder

I found the note that talks about them only being valid where @foo is allowed, which is confusing because @ocaml.doc works?

Technically /** is parsed in not exactly the same code path as @foo so this is a good question (issue) for the syntax repo. As to why there's a difference here.

cristianoc avatar Jul 20 '22 11:07 cristianoc

I think, as we get closer to release, it's time to just combine them all into one v10 section. New beta releases can have their own section, but all previous v10 updates should be combined IMO.

I don't think I'll have time to log a PR today, maybe tomorrow. Should I do it against master or the new v10 branch/PR?

v10 branch.

cristianoc avatar Jul 20 '22 11:07 cristianoc

Better example:

type z = (
  @thisIsOk  ~firstArg: bool,
  /** thisIsNotOk */
  ~secondArg: bool
) => string

cristianoc avatar Jul 20 '22 11:07 cristianoc

The rescript-lang/syntax repo is obsolete and will be archived soon. If this issue is still relevant, please reopen in the compiler repo (https://github.com/rescript-lang/rescript-compiler) or comment here to ask for it to be moved. Thank you for your contributions.

stale[bot] avatar May 28 '23 15:05 stale[bot]