Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make semicolons optional between attributes when on separate lines #18303

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Feb 9, 2025

Description

This PR makes semicolons optional between attributes when they appear on separate lines. This improves readability and reduces visual noise in multi-line attribute declarations.

Fixes # (issue, if applicable) There is an issue somewhere but could not find it.

Before this change, semicolons were required between attributes even when on separate lines:

[<Obsolete("Message 1"); 
  Obsolete("Message 2")>]

After this change, both forms are valid:

// With semicolons (existing syntax)
[<Obsolete("Message 1"); 
  Obsolete("Message 2")>]

// Without semicolons when on separate lines (new syntax)
[<Obsolete("Message 1")
  Obsolete("Message 2")>]

// Same line still requires semicolons
[<Obsolete("Message 1"); Obsolete("Message 2")>]

Checklist

  • Test cases added
  • Performance benchmarks added in case of performance changes
  • Release notes entry updated

@edgarfgp edgarfgp force-pushed the multiple-attributes-no-semicolon branch from 7b2ee78 to 386664c Compare February 9, 2025 18:49
Copy link
Contributor

github-actions bot commented Feb 9, 2025

❗ Release notes required

@edgarfgp,

Caution

No release notes found for the changed paths (see table below).

Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format.

The following format is recommended for this repository:

* <Informative description>. ([PR #XXXXX](https://github.com/dotnet/fsharp/pull/XXXXX))

See examples in the files, listed in the table below or in th full documentation at https://fsharp.github.io/fsharp-compiler-docs/release-notes/About.html.

If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request.

You can open this PR in browser to add release notes: open in github.dev

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.300.md No release notes found or release notes format is not correct

Comment on lines +2 to +3
[<MyAttribute(foo ="bar")
MyAttribute(foo ="bar")>]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth having a test where the second one is not indented far enough? Would it be considered offsides? What about a mixture of semicolons and newlines?

@auduchinok
Copy link
Member

@edgarfgp This should probably follow the logic in LexFilter for sequential expressions. Simply allowing spaces is likely to change parsing of attributes [<Attr Const>] which we don't want.

@vzarytovskii
Copy link
Member

This will also require an rfc, since it's a change to how things are lexed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: New
Development

Successfully merging this pull request may close these issues.

4 participants