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: Hash directive in computation expression #977

Closed
3 tasks
nojaf opened this issue Jul 17, 2020 · 1 comment · Fixed by #1011
Closed
3 tasks

Bug: Hash directive in computation expression #977

nojaf opened this issue Jul 17, 2020 · 1 comment · Fixed by #1011

Comments

@nojaf
Copy link
Contributor

nojaf commented Jul 17, 2020

Issue created from fantomas-online

Code

    let initDb() =
        if not (File.Exists(dbFileName)) then 
            let dbFile = File.Create(dbFileName)
            dbFile.Dispose() |> ignore
        let createSql = readSqlFile "create"
        using (connection()) (fun conn -> 
            task { 
                do! conn.OpenAsync()
                let! _ = conn.ExecuteAsync(createSql)
#if DEBUG
                let! hasClients = hasClients()
                if not (hasClients) then 
                    let seedSql = readSqlFile "seed"
                    let! _ = conn.ExecuteAsync(seedSql)
                    ()
#endif
                
            })

Error

Fantomas.FormatConfig+FormatException: Parsing failed with errors: [|tmp.fsx (18,13)-(18,14) parse error Unexpected symbol '}' in expression|]
And options: { SourceFiles = [|"tmp.fsx"|]
  ConditionalCompilationDefines = []
  ErrorSeverityOptions = { WarnLevel = 3
                           GlobalWarnAsError = false
                           WarnOff = []
                           WarnOn = []
                           WarnAsError = []
                           WarnAsWarn = [] }
  IsInteractive = false
  LightSyntax = None
  CompilingFsLib = false
  IsExe = false }
   at Fantomas.CodeFormatterImpl.parse@61-2.Invoke(FSharpParseFileResults _arg2)
   at Microsoft.FSharp.Control.AsyncPrimitives.CallThenInvokeNoHijackCheck[a,b](AsyncActivation`1 ctxt, FSharpFunc`2 userCode, b result1) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 416
   at <StartupCode$FSharp-Compiler-Service>.$Service.ParseFile@436-3.Invoke(AsyncActivation`1 ctxt) in /Users/chethusk/oss/FCS/src/fsharp/service/service.fs:line 436
   at Microsoft.FSharp.Control.Trampoline.Execute(FSharpFunc`2 firstAction) in F:\workspace\_work\1\s\src\fsharp\FSharp.Core\async.fs:line 109

Problem description

The compiler cannot create AST for some reason.

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 07/14/2020 19:31:03 - 3416b51

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 Author

nojaf commented Aug 7, 2020

The computation doesn't return anything if DEBUG is false.
There is still a bug if it does:

    let initDb() =
        if not (File.Exists(dbFileName)) then 
            let dbFile = File.Create(dbFileName)
            dbFile.Dispose() |> ignore
        let createSql = readSqlFile "create"
        using (connection()) (fun conn -> 
            task { 
                do! conn.OpenAsync()
                let! _ = conn.ExecuteAsync(createSql)
#if DEBUG
                let! hasClients = hasClients()
                if not (hasClients) then 
                    let seedSql = readSqlFile "seed"
                    let! _ = conn.ExecuteAsync(seedSql)
                    ()
#else
                ()
#endif
            })

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.

1 participant