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

Idempotency problem when using set and spread syntax #2392

Closed
1 of 3 tasks
MangelMaxime opened this issue Jul 28, 2022 · 2 comments
Closed
1 of 3 tasks

Idempotency problem when using set and spread syntax #2392

MangelMaxime opened this issue Jul 28, 2022 · 2 comments

Comments

@MangelMaxime
Copy link

Issue created from fantomas-online

Formatted code

let numeric =
    set['0' .. '9']
    + set['+'
    '-'
    '.'
    'e'
    'E']

let whitespace =
    set[','
    ':'
    '\u0009'
    '\u000a'
    '\u000d'
    '\u0020']

Reformatted code

let numeric = set['0' .. '9'] + set['+' '-' '.' 'e' 'E']

let whitespace = set[',' ':' '\u0009' '\u000a' '\u000d' '\u0020']

This code is invalid because it is missing ; separator.

Another problem with this code, is that it gives a compiler warning because there should be a space between set and the bracket [

The syntax 'expr1[expr2]' is used for indexing. Consider adding a type annotation to enable indexing, or if calling a function add a space, e.g. 'expr1 [expr2]'

Problem description

Fantomas was not able to produce the same code after reformatting the result.

Extra information

  • The formatted result breaks my code.
  • The formatted result gives compiler warnings.
  • I or my company would be willing to help fix this.

Options

Fantomas master branch at 2022-07-28T06:18:27Z - 9f5feff

Default Fantomas configuration

Did you know that you can ignore files when formatting from fantomas-tool or the FAKE targets by using a .fantomasignore file?

@nojaf
Copy link
Contributor

nojaf commented Jul 29, 2022

Hello, this is a duplicate of #2158.
In short, calling set[expr] is considered to be an indexer expression (like foo[1]) in the new F# 6 syntax.
You need to add a space in your code to tell the compiler this is a function application instead of an indexer expression. (Example)

@nojaf
Copy link
Contributor

nojaf commented Aug 24, 2022

Fixed by #2446

@nojaf nojaf closed this as completed Aug 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants