Skip to content

[Diagnostics] Suppress printing explicit pack types in the ASTPrinter instead of stripping PackType out of diagnostic arguments. #66632

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 1 commit into from
Jun 14, 2023

Conversation

hborla
Copy link
Member

@hborla hborla commented Jun 14, 2023

There are places in the type printing code that assume the substitution for a type parameter pack is always a pack, and violating that invariant will crash the compiler. We also never want to print Pack{...} in diagnostics anyway, so the print option is a better approach and fixes a few existing tests that still contained Pack{...} in error messages.

Resolves #66395, rdar://110180564

@hborla
Copy link
Member Author

hborla commented Jun 14, 2023

@swift-ci please smoke test

Copy link
Contributor

@slavapestov slavapestov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Can you use this to simplify gatherGenericParamBindingsText() in TypeCheckGeneric.cpp, too?


let _: (Array<Int>, Set<String>) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array<Pack{Int, _}>)' is not convertible to '(Array<Int>, Set<String>)', tuples have a different number of elements}}
let _: (Array<Int>, Set<String>) = patternInstantiationTupleTest1() // expected-error {{'(repeat Array<Int, _>)' is not convertible to '(Array<Int>, Set<String>)', tuples have a different number of elements}}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should expand concrete pack substitutions out in error messages so that this error message is more clear - it should say that (Array<Int>, Array<_>) is not convertible to (Array<Int>, Set<String>). I'll do that in a follow-up.

… instead of

stripping PackType out of diagnostic arguments.

There are places in the type printing code that assume the substitution for a
type parameter pack is always a pack, and violating that invariant will crash
the compiler. We also never want to print 'Pack{...}' in diagnostics anyway,
so the print option is a better approach and fixes a few existing tests that still
contained 'Pack{...}' in error messages.
@hborla hborla force-pushed the pack-diagnostics branch from 2c4f28b to e42667b Compare June 14, 2023 18:57
@hborla
Copy link
Member Author

hborla commented Jun 14, 2023

@swift-ci please smoke test

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.

Initializing non-existent property with type with parameter pack causes ICE
3 participants