Skip to content

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Apr 18, 2024

Previously code completion for 'catch' pattern bound values didn't work correctly because code completion type checker fails to type check the value decl in the pattern. E.g.

func test() throws {
  do {
    try parse(data)
  } catch ParseError.dataCorrupted(let errorMsg) {
    errorMsg.#^COMPLETE^#
  }
}

That was because the body of the 'do' statement is not type checked, so the thrown error is not determined, then falled backed to the default 'Never', which doesn't match any patterns.
To resolve this, always type check the body when type checking catch patterns. Also, pretend do {} throws any Error even without any throwing expressions in the body.
rdar://126699879

@rintaro
Copy link
Member Author

rintaro commented Apr 19, 2024

@swift-ci Please smoke test

@rintaro rintaro force-pushed the ide-complete-docatch-boundvar-rdar126699879 branch from 3d99513 to 923d180 Compare April 19, 2024 09:18
@rintaro
Copy link
Member Author

rintaro commented Apr 19, 2024

@swift-ci Please smoke test

@rintaro rintaro force-pushed the ide-complete-docatch-boundvar-rdar126699879 branch from 923d180 to 28446a7 Compare April 19, 2024 14:18
@rintaro
Copy link
Member Author

rintaro commented Apr 19, 2024

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Apr 19, 2024

I figured this doesn't cover some cases. I will revise this PR

Previously code completion for 'catch' pattern bound values didn't work
correctly because code completion type checker fails to type check the
value decl in the pattern.
That was because the body of the 'do' statement is not type checked, so
the thrown error is not determined, then falled backed to the default
'Never', which doesn't matches any patterns.
To resolve this, always type check the body when typechecking 'catch'
patterns. Also, pretends 'do {}' throws 'any Error' even without
any throwing expressions in the body.

rdar://126699879
@rintaro rintaro force-pushed the ide-complete-docatch-boundvar-rdar126699879 branch from 28446a7 to 0e12254 Compare April 22, 2024 18:11
@rintaro
Copy link
Member Author

rintaro commented Apr 22, 2024

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Apr 22, 2024

Decided to always type check the body when type checking catch patterns.

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