There was a parsing error when I tried to parse the following code:
module Darklang =
let returnsOptionNone () : Stdlib.Option.Option<'a> = Stdlib.Option.Option.None
let returnsResultOk () : Stdlib.Result.Result<Int64, String> =
Stdlib.Result.Result.Ok 5L
It was parsed as one function declaration instead of two because there wasn’t a clear delimiter; enums can have fields, so it tried to treat that second fn_decl as a field, and errored
This PR handles this issue by:
forcing the body to be written on a new line and indented for complex expressions
allowing inline expressions if they are either simple_expression, or paren_expression
This is how things work now:
// have the body on a new line and indented
let returnsOptionNone () : Stdlib.Option.Option<'a> =
Stdlib.Option.Option.None
let returnsResultOk () : Stdlib.Result.Result<Int64, String> =
Stdlib.Result.Result.Ok 5L
// or wrap it in parens
let returnsOptionNone () : Stdlib.Option.Option<'a> = (Stdlib.Option.Option.None)
let returnsResultOk () : Stdlib.Result.Result<Int64, String> =
Stdlib.Result.Result.Ok 5L
// no need for parens for simple expressions
let returnsOne () : Int64 = 1L
let returnsResultOk () : Stdlib.Result.Result<Int64, String> =
Stdlib.Result.Result.Ok 5L
No changelog
This PR fixes
fn_decl
parsingThere was a parsing error when I tried to parse the following code:
It was parsed as one function declaration instead of two because there wasn’t a clear delimiter; enums can have fields, so it tried to treat that second
fn_decl
as a field, and erroredThis PR handles this issue by:
simple_expression
, orparen_expression
This is how things work now: