Commit Graph

1350 Commits

Author SHA1 Message Date
Amritpan Kaur
366707d01b [Test] Update tests. 2023-08-16 14:28:08 -07:00
Pavel Yaskevich
cfea0d3d22 [TypeChecker] NFC: Add XFAIL'ed test-case for https://github.com/apple/swift/issues/67363 2023-08-14 10:06:52 -07:00
Pavel Yaskevich
64a654dc0d Revert "[CSBindings] Prefer conjunctions over closure variables without bindings"
This reverts commit 11ee82de7b.
2023-08-14 10:02:05 -07:00
Pavel Yaskevich
44cb14f849 Merge pull request #67441 from xedin/fix-overly-eager-closure-resolving
[CSBindings] Prefer conjunctions over closure variables without bindings
2023-08-04 09:42:50 -07:00
Amritpan Kaur
d5f0fff83c [Tests] Add and update tests 2023-07-26 20:32:30 -07:00
Pavel Yaskevich
11ee82de7b [CSBindings] Prefer conjunctions over closure variables without bindings
If a closure doesn't have a contextual type inferred yet it should
be delayed in favor of already resolved closure conjunction because
"resolving" such a closure early could miss result builder attribute
attached to a parameter the closure is passed to.

Partially resolves https://github.com/apple/swift/issues/67363
2023-07-21 09:46:09 -07:00
Crazy凡
4e346c1cf8 Add test cases for the 'nil coalescing operator'. 2023-07-04 18:21:26 +08:00
Slava Pestov
1957bd6065 Sema: Reword diagnostics to say 'without a type annotation' instead of 'without more context' 2023-06-09 17:44:42 -04:00
Luciano Almeida
fef908efac [Sema] Increase impact of ternary then branch aiming better diagnostics 2023-05-30 20:55:50 -03:00
Anthony Latsis
3f629315a9 Merge pull request #65731 from AnthonyLatsis/always-print-any
ASTPrinter: Turn on explicit `any` printing for everything and remove the option to disable it
2023-05-16 03:27:36 +03:00
Anthony Latsis
7f6d3bcd41 ASTPrinter: Turn on explicit any printing for everything and remove the option to disable it 2023-05-13 02:55:49 +03:00
Kavon Farvardin
3e4bc82aa8 rename _forget to discard; deprecate _forget
SE-390 concluded with choosing the keyword discard rather than forget for
the statement that disables the deinit of a noncopyable type. This commit
adds parsing support for `discard self` and adds a deprecation warning for
`_forget self`.

rdar://108859077
2023-05-08 21:42:19 -07:00
Kavon Farvardin
4943beb35e emit error if _forget is used on a type with no deinit
rdar://108877261
2023-05-05 14:50:48 -07:00
Pavel Yaskevich
20d7642ca4 [CSGen] Allow expression pattern types to be holes 2023-04-24 10:02:00 -07:00
Pavel Yaskevich
1c3667b52a Merge pull request #65310 from calda/cal--SE-3065-bad-pattern-check
[SE-0365] Fix issue where boolean condition before `let self` condition would prevent using implicit self
2023-04-21 09:54:27 -07:00
Hamish Knight
017794a7d7 Merge pull request #65098 from hamishknight/poundland 2023-04-21 09:26:10 +01:00
Anthony Latsis
d224efc8a8 Merge pull request #65318 from AnthonyLatsis/revert-f608802cfe498b8684e4ea63603fe99073102ce6
Revert "Sema: Emit diagnostics when walking into collection literals with defaulted types"
2023-04-21 01:26:03 +03:00
Cal Stephens
ee906f7ba5 Merge branch 'main' into cal--SE-3065-bad-pattern-check 2023-04-20 13:41:48 -07:00
Anthony Latsis
f76f6acbf0 Revert "Sema: Emit diagnostics when walking into collection literals with defaulted types"
This reverts commit f608802cfe.
2023-04-20 21:55:40 +03:00
Pavel Yaskevich
ff62be17a4 Merge pull request #65211 from calda/cal--weak-self-capture-inner-func
[SE-0365] Allow implicit self in inner functions in [weak self] closures, like with [self] closures
2023-04-19 22:48:24 -07:00
Cal Stephens
3e140286e8 Fix issue where non-pattern-binding condition would break SE-0365 unwrapped self check 2023-04-19 19:17:35 -07:00
Cal Stephens
6670639e9b Clean up implementation, add more extensive tests 2023-04-19 08:32:43 -07:00
Cal Stephens
9e55fb0ba0 Allow implicit self in inner functions in [weak self] closures, like with [self] closures 2023-04-15 09:27:20 -06:00
Anthony Latsis
8d1d526195 TypeCheckType: Fix existential 'any' migration diagnostics for extra-modular protocols 2023-04-13 03:37:25 +03:00
Hamish Knight
3f7c3a2faf Handle #if for if/switch expressions
- Allow an if/switch expression to become an
implicit return of a function that has a `#if`
body with a single active element that is an `if`
or `switch`.
- Allow `#if` branches of an if/switch expression,
as long as there is a single active expression
element.

rdar://107487977
2023-04-12 14:54:22 +01:00
Hamish Knight
bca451baa0 [Sema] Improve diagnostic for empty if expr branch
Previously we would say that it must end with a
`throw`, but a more useful diagnostic is that
there is an expression missing.
2023-04-12 14:54:22 +01:00
Pavel Yaskevich
0bdacfb4eb Merge pull request #64786 from calda/cal--64757
[SE-0365] Fix #64757: Unexpected "Implicit use of 'self' in closure" error in closure nested in result builder
2023-04-11 09:58:13 -07:00
Pavel Yaskevich
c7766763e8 Merge pull request #64846 from Rajveer100/branch-for-issue-53822
Improved Cast Diagnostics when Literals are involved
2023-04-07 20:31:58 -07:00
Rajveer
2c96e90c71 [Sema] Improved Cast Diagnostics when Literals are involved
Fixes Issue #53822
2023-04-07 00:18:02 +05:30
Allan Shortlidge
7dc313f1be NFC: Fix tests that mistakenly rely on unavailable stored properties.
Preparation for rdar://107449845
2023-04-04 08:52:39 -07:00
Cal Stephens
548456d62f Add test case for #64757 2023-04-03 18:21:02 -07:00
Kavon Farvardin
2c7d9a5047 update tests given move-only types are enabled
the main things still left behind the experimental flag(s) are
- move-only classes (guarded by MoveOnlyClasses feature)
- noimplicitcopy
- the _borrow operator
2023-03-14 18:35:13 -07:00
Anthony Latsis
31a71c8125 Merge pull request #63545 from AnthonyLatsis/robust-fixit-verifications
DiagnosticVerifier: Implement defaulting behavior for lines in expected fix-it replacement range
2023-03-08 20:10:24 +03:00
Anthony Latsis
14b70f306b DiagnosticVerifier: Default expected fix-it start line to the diagnostic's 2023-03-08 12:10:27 +03:00
Pavel Yaskevich
8b63ce8273 Merge pull request #64143 from xedin/ambiguity-diag-improvements
[ConstraintSystem] A couple of improvements to ambiguity diagnostics
2023-03-07 11:57:51 -08:00
Pavel Yaskevich
6c5186f1ca [CSFix] Diagnose missing base type unwrap in ambiguous contexts 2023-03-06 10:17:51 -08:00
Pavel Yaskevich
4f2a1752c2 [ConstraintSystem] Produce ambiguity notes based on the fix aggregate
It shouldn't matter how many fixes does the solution have overall,
what matter is how many fixes are there for the location in question.
2023-03-06 10:17:51 -08:00
Michael Gottesman
0ad5a18d40 Update test output. 2023-03-03 18:19:26 -08:00
Michael Gottesman
c97121d3ee [reference-binding] Add support for inout binding parsing/serialization. 2023-03-01 20:48:54 -08:00
Hamish Knight
f7423b9a82 Merge pull request #63994 from hamishknight/context-switch
Resolves https://github.com/apple/swift/issues/63750
2023-03-01 22:06:37 +00:00
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
Kavon Farvardin
8559d3c6ea fix issue printing the forget statement in the AST
`kw_forget` isn't covered by `operator<<` since it's
not a normal keyword.
2023-02-28 23:31:34 -08:00
Luciano Almeida
22a18de1b1 [Sema] Improving integer literal as boolean diagnostic 2023-02-21 10:30:48 -03:00
Pavel Yaskevich
8e82f1d68b [CSGen] Detect nested out-of-scope variables in recursive declarations
Follow-up to https://github.com/apple/swift/pull/63505

Since, when the type is not stated, a variable assumes the
type of its initializer that enables out-of-scope variables
to be nested inside of some other concrete type i.e. Optional.

Resolves: https://github.com/apple/swift/issues/63455
2023-02-11 19:19:09 -08:00
Pavel Yaskevich
bffb8d9ee2 Revert "[CSGen] Handle recursive use of variable declarations" 2023-02-10 16:45:59 -08:00
Pavel Yaskevich
83dd93ad2e [CSGen] Handle recursive use of variable declarations
It's possible for out-of-scope type variable to be the type of
declaration if such declaration is recursively referenced in
the body of a closure located in its initializer expression.
In such cases type of the variable declaration cannot be connected
to the closure because its not known in advance (determined by the
initializer itself).

Resolves: https://github.com/apple/swift/issues/63455
2023-02-07 17:48:26 -08:00
Hamish Knight
0d55f45d95 [Sema] Error on redundant try/awaits for if/switch expressions
Look through `try`/`await` markers when looking for
out of place if/switch expressions, and customize
the effect checking diagnostic such that we error
that `try`/`await` are redundant on `if`/`switch`
expressions.
2023-02-01 15:30:19 +00:00
Hamish Knight
a40f1abaff Introduce if/switch expressions
Introduce SingleValueStmtExpr, which allows the
embedding of a statement in an expression context.
This then allows us to parse and type-check `if`
and `switch` statements as expressions, gated
behind the `IfSwitchExpression` experimental
feature for now. In the future,
SingleValueStmtExpr could also be used for e.g
`do` expressions.

For now, only single expression branches are
supported for producing a value from an
`if`/`switch` expression, and each branch is
type-checked independently. A multi-statement
branch may only appear if it ends with a `throw`,
and it may not `break`, `continue`, or `return`.

The placement of `if`/`switch` expressions is also
currently limited by a syntactic use diagnostic.
Currently they're only allowed in bindings,
assignments, throws, and returns. But this could
be lifted in the future if desired.
2023-02-01 15:30:18 +00:00
Pavel Yaskevich
ccb35fe967 Merge pull request #63083 from xedin/rdar-104302974
[CSSimplify] Report unresolved base failure if leading-dot syntax bas…
2023-01-20 17:36:01 -08:00
Pavel Yaskevich
7b9cffd40a [CSSimplify] Fix should propagate contextual type into optional chain with leading-dot syntax
Member chains with leading-dot syntax can infer the base type
only from context, so optionality mismatch with the contextual
type should propagate object type down the chain.
2023-01-20 09:47:33 -08:00