You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi! I've been testing out pyre-ast as I'd like to use it in a project, and came across this behaviour:
If I call PyreAst.Parser.Concrete.parse_expression with "x = 4", I get an invalid syntax error, but the same does not occur when I use PyreAst.Parser.Concrete.parse_module. Why is this the case? I thought it would behave the same in both cases.
Code I used to test pyre-ast:
let example content =
let open PyreAst.Parser in
with_context (fun context ->
(* replace parse_module here with parse_expression to get the error *)
match Concrete.parse_expression ~context content with
| Result.Error { Error.message; line; column; _ } ->
let message =
Format.sprintf "Parsing error at line %d, column %d: %s"
line column message
in
failwith message
| Result.Ok ast -> ast
)
let () =
let ast = example "x = 4" in
(* replace PyreAst.Concrete.Module with PyreAst.Concrete.Expression if you replace parse_module *)
Sexplib0.Sexp.pp_hum Format.std_formatter (PyreAst.Concrete.Expression.sexp_of_t ast)
Error I received when parsing "x = 4" with parse_expression
Fatal error: exception Failure("Parsing error at line 1, column 3: invalid syntax")
Raised at Stdlib.failwith in file "stdlib.ml", line 29, characters 17-33
Called from Base__Exn.protectx in file "src/exn.ml", line 80, characters 8-11
Re-raised at Base__Exn.raise_with_original_backtrace in file "src/exn.ml" (inlined), line 60, characters 2-48
Called from Base__Exn.protectx in file "src/exn.ml", line 87, characters 13-49
Called from Dune__exe__Main in file "bin/main.ml", line 16, characters 12-27
The text was updated successfully, but these errors were encountered:
Hi! I've been testing out pyre-ast as I'd like to use it in a project, and came across this behaviour:
If I call
PyreAst.Parser.Concrete.parse_expression
with "x = 4", I get an invalid syntax error, but the same does not occur when I usePyreAst.Parser.Concrete.parse_module
. Why is this the case? I thought it would behave the same in both cases.Code I used to test pyre-ast:
Error I received when parsing "x = 4" with
parse_expression
The text was updated successfully, but these errors were encountered: