Commit Graph

8 Commits

Author SHA1 Message Date
Rintaro Ishizaki
0e122544ca [CodeCompletion] Fix completion for 'catch' pattern bound values
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
2024-04-22 11:09:12 -07:00
Doug Gregor
ea836389f7 Suppress warnings about Never error types in catch clauses
Enabling typed throws has introduced some spurious warnings about error
values of `Never` type on top of the custom "unreachable" diagnostics
for catch clauses, so suppress the new warnings---they aren't helpful.
2024-01-04 09:37:35 -08:00
Rajveer
c34f099c7d Improved out-of-place binding diagnostic and reflecting 'var' or 'let' binding pattern
Fixes Issue #63993
2023-03-19 19:26:58 +05:30
Hamish Knight
043b192dcd [Sema] Diagnose duplicate pattern vars in pattern resolution
Unify the duplicate pattern var checking in
pattern resolution such that it is always called
no matter how we end up type-checking the pattern.
This avoids incorrectly allowing duplicate pattern
vars to compile for patterns as a part of
multi-statement closures.
2023-03-01 16:20:14 +00:00
Slava Pestov
5808d9beb9 Parse: Remove parse-time name lookup 2020-11-16 22:39:44 -05:00
Slava Pestov
6a5684a76c Sema: Allow duplicate internal parameter names on protocol requirements
This fixes a recent source compatibility regression.

Fixes <rdar://problem/70445751>.
2020-10-19 16:02:14 -04:00
Slava Pestov
6042784578 Sema: Tweak re-declaration checking behavior to match old logic
The parser's own re-declaration checking for local declarations has
slightly different behavior than Sema's re-declaration check.

Whereas Sema rejects this:

class C {
  let x = 123
  func x() {}
}

The parser accepts this:

func f() {
  let x = 123
  func x() {}
}

With Sema's check now handling both cases, fudge the behavior to
match the parser in the local case.
2020-10-01 23:46:26 -04:00
Slava Pestov
18f5f94ce2 Sema: Check for duplicate parameter and generic parameter names when parser lookup is off
The existing redeclaration checking can be extended for declarations in
local scope, but it won't catch these.
2020-09-29 23:38:24 -04:00