Skip to content

Conversation

PaulTaykalo
Copy link
Contributor

@PaulTaykalo PaulTaykalo commented Sep 30, 2017

AST Dumper at the moment generates invalid AST dump output for enum_is_case_expr
Currently it forgets to add a closing bracket, which leads to unparsable AST dump output.

(if_stmt implicit\
  (call_expr implicit type='Int1' nothrow arg_labels=\
    (dot_syntax_call_expr implicit type='() -> Int1' nothrow\
      (declref_expr implicit type='(Bool) -> () -> Int1' decl=Swift.(file).Bool._getBuiltinLogicValue() function_ref=double)\
      (enum_is_case_expr implicit type='Bool' some\
        (declref_expr implicit type='UIBarButtonItem?' decl=The.(file).Controller.<anonymous>.tmp1 direct_to_storage function_ref=unapplied))\                   # <--- One Bracked is missing here
    (tuple_expr implicit type='()'))\
  (return_stmt implicit\
    (force_value_expr implicit type='UIBarButtonItem'\
      (declref_expr implicit type='UIBarButtonItem?' decl=The.(file).Controller.<anonymous>.tmp1 direct_to_storage function_ref=unapplied))))\

AST Dumper at the moment generates invalid AST dump output for `enum_is_case_expr`
Currently it `forgets` to add a closing bracket, which leads to unparsable AST dump output.
```
          (if_stmt implicit\
            (call_expr implicit type='Int1' nothrow arg_labels=\
              (dot_syntax_call_expr implicit type='() -> Int1' nothrow\
                (declref_expr implicit type='(Bool) -> () -> Int1' decl=Swift.(file).Bool._getBuiltinLogicValue() function_ref=double)\
                (enum_is_case_expr implicit type='Bool' some\
                  (declref_expr implicit type='UIBarButtonItem?' decl=The.(file).Controller.<anonymous>.tmp1 direct_to_storage function_ref=unapplied))\                   # <--- One Bracked is missing here
              (tuple_expr implicit type='()'))\
            (return_stmt implicit\
              (force_value_expr implicit type='UIBarButtonItem'\
                (declref_expr implicit type='UIBarButtonItem?' decl=The.(file).Controller.<anonymous>.tmp1 direct_to_storage function_ref=unapplied))))\
```
@CodaFi
Copy link
Contributor

CodaFi commented Sep 30, 2017

Wow! Thanks for catching this.

@swift-ci please smoke test

@CodaFi
Copy link
Contributor

CodaFi commented Sep 30, 2017

By the way, I really hope this

which leads to unparsable AST dump output.

means that you aren't trying to parse dumped ASTs. If you are, have you taken a look at libSyntax?

@PaulTaykalo
Copy link
Contributor Author

@CodaFi Actually, I do.
I'm using it for input for another tool I'm working on. I found that parsing AST dump was way easier than trying to add custom plugin to swiftc to get info about AST
Thanks for the reference.

@CodaFi
Copy link
Contributor

CodaFi commented Sep 30, 2017

Just to be clear: we make no guarantees about the stability of the AST dump format. If your tool is written in Swift, we have Swift bindings to libSyntax for you to use as well.

@CodaFi
Copy link
Contributor

CodaFi commented Sep 30, 2017

⛵️

@CodaFi CodaFi merged commit cd18c38 into swiftlang:master Sep 30, 2017
@PaulTaykalo PaulTaykalo deleted the ast-dump-enum-case-expression-fix branch October 1, 2017 07:15
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 this pull request may close these issues.

2 participants