Commit Graph

1470 Commits

Author SHA1 Message Date
Luciano Almeida
9c9af903bb [test] Add opaque result type cases 2022-09-05 10:29:16 -03:00
Luciano Almeida
7300fb5836 [Sema] Improve diagnostic for closure return contextual mismatch 2022-09-04 22:28:49 -03:00
Anthony Latsis
867472491f Merge pull request #60812 from AnthonyLatsis/migrate-test-suite-to-gh-issues-12
Gardening: Migrate test suite to GH issues p. 12
2022-09-02 06:06:53 +03:00
Anthony Latsis
5b245b42cd Merge pull request #60836 from AnthonyLatsis/migrate-test-suite-to-gh-issues-13
Gardening: Migrate test suite to GH issues p. 13
2022-09-02 06:06:14 +03:00
Cal Stephens
c3e74e06b4 Use a single warning, but dynamically specify 'nil' or 'Optional.none' 2022-09-01 09:10:01 -07:00
Cal Stephens
c2bf0f943e Revert "Combine the two diagnostics"
This reverts commit 2e7656218e.
2022-09-01 08:11:46 -07:00
Cal Stephens
1b224bd945 Add a test that verifyies comparing to a .none case that isn't Optional.none still works 2022-09-01 06:38:50 -07:00
Cal Stephens
2e7656218e Combine the two diagnostics 2022-09-01 06:23:42 -07:00
Cal Stephens
88b65f406f Update tests 2022-08-31 20:14:41 -07:00
Anthony Latsis
d911aad234 Gardening: Migrate test suite to GH issues: expr/unary 2022-08-30 00:31:18 +03:00
Anthony Latsis
65663b0b5d Gardening: Migrate test suite to GH issues: expr/primary 2022-08-30 00:31:18 +03:00
Anthony Latsis
2a220d5d1b Gardening: Migrate test suite to GH issues: expr/postfix 2022-08-30 00:31:18 +03:00
Anthony Latsis
8cd1df47ce Gardening: Migrate test suite to GH issues: expr/delayed-ident 2022-08-30 00:31:18 +03:00
Luciano Almeida
109737551e [Sema] Handle non-function type parameters for closure arguments in ambiguity diagnositc 2022-08-27 20:42:19 -03:00
Anthony Latsis
6c615c8ead Gardening: Migrate test suite to GH issues: expr/closure 2022-08-27 05:26:00 +03:00
Anthony Latsis
5324bf9773 Gardening: Migrate test suite to GH issues: expr/cast 2022-08-27 03:15:21 +03:00
Anthony Latsis
45f5f08fa0 Gardening: Migrate test suite to GH issues: expr 2022-08-26 22:20:52 +03:00
Pavel Yaskevich
3ebc541fd5 [CSDiagnostics] Verify that member is in collection context
`MissingMemberFailure::diagnoseInLiteralCollectionContext`
should verify that a parent (or parent of a parent) expression
is indeed a collection expression instead of checking types.

Resolves: rdar://91452726
2022-08-17 12:12:27 -07:00
Sima Nerush
f608802cfe Sema: Emit diagnostics when walking into collection literals with defaulted types
Resolves https://github.com/apple/swift/issues/60011

Gardening: clean up `checkTypeDefaultedCollectionExpr` function
2022-08-15 22:45:21 -06:00
Alex Hoppen
e14fa7291f [CS] Don’t fail constraint generation for ErrorExpr or if type fails to resolve
Instead of failing constraint generation by returning `nullptr` for an `ErrorExpr` or returning a null type when a type fails to be resolved, return a fresh type variable. This allows the constraint solver to continue further and produce more meaningful diagnostics.

Most importantly, it allows us to produce a solution where previously constraint generation for a syntactic element had failed, which is required to type check multi-statement closures in result builders inside the constraint system.
2022-07-20 09:46:12 +02:00
Cal Stephens
778a2fc1f5 Merge branch 'main' into cal--implicit-weak-self 2022-07-18 10:00:23 -07:00
Luciano Almeida
11877d7a1b [Sema][Revert] Revert CTP to CTP_ReturnStmt for closure result in return stmt 2022-07-15 09:31:11 -03:00
Luciano Almeida
44f4eba6c5 [Sema] Add return context valid source loc to implicit tuple expr context for diagnostic 2022-07-11 20:57:54 -03:00
Anthony Latsis
15acfa9a5b Merge pull request #59535 from AnthonyLatsis/close-issues-1
Add regression tests to close some issues
2022-06-23 20:43:51 +03:00
Anthony Latsis
4d3aa95d59 Add regression test to close #42790 2022-06-22 22:17:30 +03:00
Pavel Yaskevich
566e00c057 Merge pull request #59305 from xedin/rdar-94360230
[ConstraintSystem] Use '# of overloads' as a tie-breaker in ambiguities
2022-06-17 12:20:07 -07:00
Pavel Yaskevich
7ba07ae3ba Merge pull request #59210 from xedin/conflicting-patterns-in-case
[Diagnostics] Diagnose conflicting pattern variables
2022-06-14 11:30:34 -07:00
Pavel Yaskevich
8f69b9f2e0 [ConstraintSystem] Use '# of overloads' as a tie-breaker in ambiguities
The deepest expression is the one that introduced the ambiguity into
the chain, so depth and index should be deciding factors and number of
overloads - a tie-breaker, while choosing what to diagnose.

Resolves: rdar://94360230
2022-06-07 15:53:13 -07:00
Serena
e05f68c822 Change diagnostic error thrown for when string interpolations aren't closed by a parenthesis (#58882)
[Parse] Diagnose unclosed string interpolations
2022-06-04 19:32:41 +03:00
Pavel Yaskevich
9c8bebe4f8 [CSClosure] Detect and diagnose conflicting pattern variables in case statements
Avoid mutating case label items while solving, instead let's use types
recorded in the constraint system for each pattern variable and use
that for var reference in the case body. This also helps to detect
and diagnose type conflicts while solving.
2022-06-03 16:35:18 -07:00
Pavel Yaskevich
1099cca050 Merge pull request #59238 from xedin/rdar-92757114-test
[CSClosure] NFC: Add a test-case for rdar://92757114
2022-06-03 16:28:04 -07:00
Pavel Yaskevich
c581497bd4 [CSClosure] NFC: Add a test-case for rdar://92757114
Used to produce a fallback `type of expression ...` diagnostic
2022-06-03 12:21:06 -07:00
Pavel Yaskevich
df1e38ff36 [TypeChecker] NFC: Add test-case for rdar://93061432 2022-05-30 23:17:41 -07:00
Pavel Yaskevich
d461eab3f0 [TypeChecker] Effects: Don't diagnose implicit AST nodes
Implicitly generated code requires checking but it doesn't have
to produce a diagnostic into the void.
2022-05-30 23:17:41 -07:00
Pavel Yaskevich
a6ffb09fad Merge pull request #59134 from xedin/rdar-94049113
[CSClosure] Perform syntactic checks on rewritten statements
2022-05-30 22:10:59 -07:00
Anthony Latsis
b2e2bab7e0 DiagnosticEngine: Print any in 'aka' types 2022-05-29 21:55:31 +03:00
Pavel Yaskevich
953095a9ce [CSClosure] Perform syntactic checks on rewritten statements
Fix an oversight where syntactic checking was not performed on
any statements in a body of a multi-statement after successful
solution application.

Resolves: rdar://94049113
2022-05-27 14:51:27 -07:00
Pavel Yaskevich
4e9992c261 [CSClosure] Fix crash in fallthrough statement checking
`fallthrough` requires both source and destination `case`
"preambles" be type-checked before it could be validated,
which means that solution application for `case` statements
in a `switch` has to be split in two - preamble first and
bodies afterwards.

Resolves: https://github.com/apple/swift/issues/59035
Resolves: rdar://93796211
2022-05-24 14:20:42 -07:00
Pavel Yaskevich
0e8ece615f Merge pull request #58834 from xedin/var-finder-return-handling
[CSClosure] Fix per-element variable finder to correctly handle retur…
2022-05-18 18:02:14 -07:00
Pavel Yaskevich
569333135c Merge pull request #58768 from xedin/redecl-check-in-multi-closures
[CSClosure] Diagnose invalid re-declarations in multi-statement closures
2022-05-18 15:03:41 -07:00
Pavel Yaskevich
c7b150506a Merge pull request #58905 from xedin/improve-relabeling-diagnostic
[Diagnostics] Diagnose re-labeling failures in ambiguity conditions
2022-05-18 15:01:20 -07:00
Pavel Yaskevich
ddd7e495dd [CSClosure] Fix per-element variable finder to correctly handle return statements
Type finder is still allowed to walk into closures to find any
referenced variables, but it should bring external result type
into scope only if a particular `return` belongs to the same
closure as the element.
2022-05-18 13:52:34 -07:00
Pavel Yaskevich
dfadee3731 [CSDiagnostics] Attach missing member diagnostic to a pattern/statement
If missing member is found in e.g. case statement or a pattern,
let's attach diagnostic directly to it.
2022-05-18 00:28:08 -07:00
Pavel Yaskevich
f3ff87b6f4 [Diagnostics] Diagnose re-labeling failures in ambiguity conditions
If all solutions point to the same overload choice that needs
re-labeling it's safe to diagnose it as if there was no ambiguity
because the call site is static.
2022-05-13 14:25:14 -07:00
Pavel Yaskevich
854f64eff5 [CSClosure] Diagnose invalid re-declarations in multi-statement closures
Calling `typeCheckDecl` on `VarDecl` is what triggers re-declaration
checking and that was skipped by the solution application logic.
2022-05-09 12:50:39 -07:00
Pavel Yaskevich
67895c2927 [CSClosure] Mark partially inferred external declarations as invalid
If a syntactic element references an external declaration (relative
to its own context), let's check whether it has any type variables,
and if so, replace them with errors to remove any possibility of
bringing external constraints into element's scope.

Resolves: rdar://92347054
2022-05-05 11:44:26 -07:00
Josh Soref
92a1c4bc28 Spelling test expr (#58577)
* spelling: expressions

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: lousy

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: refers

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: should

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-05-04 14:16:58 -07:00
Hamish Knight
04bf10b497 Merge pull request #58524 from hamishknight/condtrail 2022-04-29 19:03:57 +01:00
Pavel Yaskevich
2c140bdf4d Merge pull request #58503 from xedin/rdar-92366212
[ConstraintSystem] Fail `~=` synthesis if constraint generation fails
2022-04-29 10:19:01 -07:00
Hamish Knight
c5a53ef73e [Sema] Don't warn on trailing closures in closure conditions
Add ClosureExpr to the list of expressions we don't
walk into for the purposes of diagnosing trailing
closures in conditional initializers.

rdar://92521618
2022-04-29 14:47:19 +01:00