-
-
Notifications
You must be signed in to change notification settings - Fork 190
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
Exception: Unexpected scenario when formatting else if / elif #713
Comments
Hey @tatumalenko, thanks for reporting this. I should debug these examples to find what is going wrong. |
After some debugging, I found out I made a wrong assumption that only the last Turns out every ImplFile
(ParsedImplFileInput
("Script.fsx",true,QualifiedNameOfFile Script$fsx,[],[],
[SynModuleOrNamespace
([Script],false,AnonModule,
[DoExpr
(NoSequencePointAtDoBinding,
IfThenElse
(App
(NonAtomic,false,
App
(NonAtomic,true,Ident op_LessThan,Ident v1,
Script.fsx (1,3--1,7) IsSynthetic=false),Ident v2,
Script.fsx (1,3--1,10) IsSynthetic=false),
Const (Int32 -1,Script.fsx (2,4--2,6) IsSynthetic=false),
Some
(IfThenElse
(App
(NonAtomic,false,
App
(NonAtomic,true,Ident op_GreaterThan,Ident v1,
Script.fsx (3,5--3,9) IsSynthetic=false),Ident v2,
Script.fsx (3,5--3,12) IsSynthetic=false),
Const (Int32 1,Script.fsx (4,4--4,5) IsSynthetic=false),
Some
(IfThenElse
(App
(NonAtomic,false,
App
(NonAtomic,true,Ident op_LessThan,Ident t1,
Script.fsx (6,7--6,11) IsSynthetic=false),
Ident t2,
Script.fsx (6,7--6,14) IsSynthetic=false),
Const
(Int32 -1,
Script.fsx (7,8--7,10) IsSynthetic=false),
Some
(IfThenElse
(App
(NonAtomic,false,
App
(NonAtomic,true,Ident op_GreaterThan,
Ident t1,
Script.fsx (8,9--8,13) IsSynthetic=false),
Ident t2,
Script.fsx (8,9--8,16) IsSynthetic=false),
Const
(Int32 1,
Script.fsx (9,8--9,9) IsSynthetic=false),
Some
(Const
(Int32 0,
Script.fsx (11,8--11,9) IsSynthetic=false)),
SequencePointAtBinding
Script.fsx (8,4--8,21) IsSynthetic=false,
false,
Script.fsx (8,4--8,21) IsSynthetic=false,
Script.fsx (8,4--11,9) IsSynthetic=false)),
SequencePointAtBinding
Script.fsx (6,4--6,19) IsSynthetic=false,false,
Script.fsx (6,4--6,19) IsSynthetic=false,
Script.fsx (6,4--11,9) IsSynthetic=false)),
SequencePointAtBinding
Script.fsx (3,0--3,17) IsSynthetic=false,false,
Script.fsx (3,0--3,17) IsSynthetic=false,
Script.fsx (3,0--11,9) IsSynthetic=false)),
SequencePointAtBinding Script.fsx (1,0--1,15) IsSynthetic=false,
false,Script.fsx (1,0--1,15) IsSynthetic=false,
Script.fsx (1,0--11,9) IsSynthetic=false),
Script.fsx (1,0--11,9) IsSynthetic=false)],PreXmlDocEmpty,[],None,
Script.fsx (1,0--11,9) IsSynthetic=false)],(true, true))) Hmm, not sure how to tackle this one yet. Ongoing investigation. |
I was able to find a way to correct all elif ranges. |
Issue created from fantomas-ui
Exception throws when formatting certain patterns of nested else if / elif blocks. Likely related to [#675] which was recently closed and fixed in [#678].
Code Example 1
Code Example 2
Another example slightly tweaked taken from [#675]:
Changing the
elif
into anelse if
in the previous example will format successfully.Code Example 3
Yet another example, again similar to the previous one, here the issue still arises but no
elif
were involved:The above still throws even if
if la > lb then a' else b'
is replaced simply witha'
(i.e. nesting only inside theelse
).Note
In all cases, if strict mode is enabled, the format succeeds.
Error
Options
Fantomas Next - 3.3.0-3/2/2020
IndentOnTryWith
false
IndentSpaceNum
2
KeepNewlineAfter
false
MaxIfThenElseShortWidth
40
PageWidth
90
ReorderOpenDeclaration
false
SemicolonAtEndOfLine
false
SpaceAfterComma
true
SpaceAfterSemicolon
true
SpaceAroundDelimiter
true
SpaceBeforeArgument
true
SpaceBeforeColon
false
SpaceBeforeSemicolon
false
StrictMode
false
The text was updated successfully, but these errors were encountered: