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

Bug: Line break before bracket on long method call followed by member access causes semantic change #994

Closed
1 of 3 tasks
reinux opened this issue Aug 12, 2020 · 2 comments · Fixed by #1020
Closed
1 of 3 tasks

Comments

@reinux
Copy link

reinux commented Aug 12, 2020

Issue created from fantomas-online

Code

Microsoft.FSharp.Reflection.FSharpType.GetUnionCases(typeof<option<option<unit>>>.GetGenericTypeDefinition().MakeGenericType(t)).Assembly

Result

Microsoft.FSharp.Reflection.FSharpType.GetUnionCases
    (typeof<option<option<unit>>>.GetGenericTypeDefinition().MakeGenericType(t)).Assembly

Problem description

Because of the line break inserted before the bracket, FSC interprets GetUnionCases in the output to be a function rather than a method.

Typed AST of source:

[Entity
   (Tmp,
    [InitAction
       Call
  (None, val raise, [], [type Microsoft.FSharp.Core.obj],
   [Const (1, type Microsoft.FSharp.Core.int32)])])]

Typed AST of Fantomas output:

[Entity
   (Tmp,
    [InitAction
       Call
  (None, val raise, [],
   [type Microsoft.FSharp.Reflection.UnionCaseInfo Microsoft.FSharp.Core.[]],
   [Const (1, type Microsoft.FSharp.Core.int32)])])]

Extra information

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

Options

Fantomas Master at 08/10/2020 06:52:52 - 6d8f084

Name Value
IndentSize 4
MaxLineLength 120
SemicolonAtEndOfLine false
SpaceBeforeParameter true
SpaceBeforeLowercaseInvocation true
SpaceBeforeUppercaseInvocation false
SpaceBeforeClassConstructor false
SpaceBeforeMember false
SpaceBeforeColon false
SpaceAfterComma true
SpaceBeforeSemicolon false
SpaceAfterSemicolon true
IndentOnTryWith false
SpaceAroundDelimiter true
MaxIfThenElseShortWidth 40
MaxInfixOperatorExpression 50
MaxRecordWidth 40
MaxArrayOrListWidth 40
MaxValueBindingWidth 40
MaxFunctionBindingWidth 40
MultilineBlockBracketsOnSameColumn false
NewlineBetweenTypeDefinitionAndMembers false
KeepIfThenInSameLine false
MaxElmishWidth 40
SingleArgumentWebMode false
AlignFunctionSignatureToIndentation false
AlternativeLongMemberDefinitions false
StrictMode false
@nojaf
Copy link
Contributor

nojaf commented Sep 18, 2020

Hey @reinux, would it be possible to provide the full sample code for this?
I'm working on #501 and my changes would change the outcome of this issue to

Microsoft.FSharp.Reflection.FSharpType.GetUnionCases(typeof<option<option<unit>>>
        .GetGenericTypeDefinition()
        .MakeGenericType(t))
    .Assembly

I'd like to be sure that this code still works when outputted like this.
What is t in this case?

@reinux
Copy link
Author

reinux commented Sep 23, 2020

Hey, I've been trying to find it in my code, but I can't :(

I may have removed it. I can't quite remember what I was trying to do with that code either.

Sorry about that.

I'm trying it out now, and it looks like that .Assembly might be misplaced. There's a good chance I just typed up some semi-random stuff in fantomas-online that exposed the problem without sharing my own actual code.

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

Successfully merging a pull request may close this issue.

2 participants