Skip to content

[ConstraintSystem] Improve ast printing in the type inference algorithm debug output #59854

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

Merged
merged 2 commits into from
Jul 4, 2022

Conversation

amritpan
Copy link
Member

@amritpan amritpan commented Jul 1, 2022

This reduces the output produced during AST printing in the type inference algorithm debug output by eliminating the list of overloaded decl references, as this information appears later under Inactive Constraints, where it is more useful.

For example, the following:

(binary_expr type='$T3' location=/Users/amritpankaur/test.swift:53:5 range=[/Users/amritpankaur/test.swift:53:1 - line:53:7]
  (overloaded_decl_ref_expr type='$T0' location=/Users/amritpankaur/test.swift:53:5 range=[/Users/amritpankaur/test.swift:53:5 - line:53:5] name=+ number_of_decls=34 function_ref=single decls=[
    Swift.(file).String extension.+,
    Swift.(file).Duration extension.+,
    Swift.(file).Float16 extension.+,
    Swift.(file).Float extension.+,
    Swift.(file).Double extension.+,
    Swift.(file).UInt8 extension.+,
    Swift.(file).Int8 extension.+,
    Swift.(file).UInt16 extension.+,
    Swift.(file).Int16 extension.+,
    Swift.(file).UInt32 extension.+,
    Swift.(file).Int32 extension.+,
    Swift.(file).UInt64 extension.+,
    Swift.(file).Int64 extension.+,
    Swift.(file).UInt extension.+,
    Swift.(file).Int extension.+,
    ... // 20 additional dec references )
  (argument_list implicit
    (argument
      (string_literal_expr type='$T1' location=/Users/amritpankaur/test.swift:53:1 range=[/Users/amritpankaur/test.swift:53:1 - line:53:1] encoding=utf8 value="a" builtin_initializer=**NULL** initializer=**NULL**))
    (argument
      (integer_literal_expr type='$T2' location=/Users/amritpankaur/test.swift:53:7 range=[/Users/amritpankaur/test.swift:53:7 - line:53:7] value=2 builtin_initializer=**NULL** initializer=**NULL**))
  ))

is reduced to :

(binary_expr type='$T3' location=/Users/amritpankaur/test.swift:53:5 range=[/Users/amritpankaur/test.swift:53:1 - line:53:7]
  (overloaded_decl_ref_expr type='$T0' location=/Users/amritpankaur/test.swift:53:5 range=[/Users/amritpankaur/test.swift:53:5 - line:53:5] name=+ number_of_decls=34 function_ref=single)
  (argument_list implicit
    (argument
      (string_literal_expr type='$T1' location=/Users/amritpankaur/test.swift:53:1 range=[/Users/amritpankaur/test.swift:53:1 - line:53:1] encoding=utf8 value="a" builtin_initializer=**NULL** initializer=**NULL**))
    (argument
      (integer_literal_expr type='$T2' location=/Users/amritpankaur/test.swift:53:7 range=[/Users/amritpankaur/test.swift:53:7 - line:53:7] value=2 builtin_initializer=**NULL** initializer=**NULL**))))

This reduction will make the printed AST easier to read.

@xedin xedin self-requested a review July 1, 2022 22:59
@amritpan amritpan changed the title Improve ast printing in the type inference algorithm debug output [ConstraintSystem] Improve ast printing in the type inference algorithm debug output Jul 2, 2022
…end of AST in Initial Constraints and in the fully Type-checked expression.
@amritpan amritpan force-pushed the improve-ast-printing branch from b32d774 to 482db15 Compare July 2, 2022 04:07
@xedin
Copy link
Contributor

xedin commented Jul 2, 2022

@swift-ci please test

@xedin xedin merged commit ceae9fd into swiftlang:main Jul 4, 2022
@amritpan amritpan deleted the improve-ast-printing branch July 8, 2022 21:00
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