Commit Graph

228 Commits

Author SHA1 Message Date
Amritpan Kaur
366707d01b [Test] Update tests. 2023-08-16 14:28:08 -07:00
Amritpan Kaur
d5f0fff83c [Tests] Add and update tests 2023-07-26 20:32:30 -07: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
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
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
Pavel Yaskevich
6c5186f1ca [CSFix] Diagnose missing base type unwrap in ambiguous contexts 2023-03-06 10:17:51 -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
Robert Widmann
37e7052c68 Remove -emit-syntax and -verify-syntax-tree 2022-11-16 15:07:48 -08:00
Allan Shortlidge
f79d91aeb5 Sema: Fix crash when diagnosing async let bindings in illegal contexts.
Resolves rdar://101673476
2022-11-01 08:55:55 -07:00
Anthony Latsis
d911aad234 Gardening: Migrate test suite to GH issues: expr/unary 2022-08-30 00:31:18 +03: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
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
5331e276d5 Merge pull request #41730 from xedin/se-0326-solve-pattern-bindings-via-conjunctions
[SE-0326] Re-enable multi-statement closure inference by default
2022-03-15 13:21:03 -07:00
Pavel Yaskevich
966f58f044 [Tests] NFC: Adjust all the test-cases improved by multi-statement inference 2022-03-08 01:13:44 -08:00
Holly Borla
12459cff80 [Diagnostics] Print 'any' in diagnostic arguments. 2022-03-05 14:26:45 -08:00
Pavel Yaskevich
bc54bc6bb7 Revert "[TypeChecker] SE-0326: Enable multi-statement closure inference by default" 2021-11-29 17:26:08 -08:00
Pavel Yaskevich
63f355fde0 Merge pull request #39989 from xedin/more-diag-improvements-for-multi-stmt-closures
[TypeChecker] SE-0326: Enable multi-statement closure inference by default
2021-11-17 10:14:58 -08:00
Pavel Yaskevich
67d87e104f [Tests] NFC: Adjust all the test-cases improved by multi-statement inference 2021-11-15 16:42:06 -08:00
Hamish Knight
d6ac93efb1 [CS] Don't set parsed paths for dynamic member key paths
The logic here could form AST loops due to passing
in `anchor` for the key path's parsed path.

However setting a parsed path here seems to be a
holdover from the CSDiag days, so set the path to
`nullptr` and rip out and the rest of the synthesis
and SanitizeExpr logic for it.

rdar://85236369
2021-11-15 12:25:17 +00:00
Pavel Yaskevich
d21069b3e5 [ConstraintSystem] Propagate holes up to result of optional chaining
If underlying type of an optional chain has been marked as a hole,
e.g. due to a reference to an invalid or missing member, let's
propagate that information to object type of an optional that
represents a result of an optional chain.

Resolves: rdar://80941497
2021-09-10 21:32:51 -07:00
Doug Gregor
eeeea49764 Remove -enable-experimental-concurrency almost everywhere. 2021-07-26 21:24:43 -07:00
Doug Gregor
1e2012d816 Disable availability checking in tests that use concurrency 2021-07-20 12:46:26 -07:00
Pavel Yaskevich
ba1b67a1ee [TypeChecker] NFC: Add a couple test-cases of partial key path inference 2021-05-28 17:54:06 -07:00
Pavel Yaskevich
0c75593a04 [CSBindings] Fix inference of partial key path from conversion constraints
It's not permitted to use `PartialKeyPath` type to resolve a key path
expression, because that type is intended to be a type-erased version of
a fully resolved `KeyPath` type.

In situations where contextual type is a partial key path (e.g. parameter
type is a partial key path), let's replace it with a `KeyPath` type that
is a subtype of `PartialKeyPath` and allow value inference to happen.

Resolves: SR-5667
Resolves: rdar://32365183
2021-05-28 17:54:05 -07:00
Luciano Almeida
c6804668de Merge pull request #37521 from LucianoPAlmeida/SR-14644-keypath
[Sema][Diagnostics][SR-14644] Improving diagnostics for key path with invalid components
2021-05-20 11:53:00 -03:00
Luciano Almeida
9f42c6995b [tests] Add regression tests for SR-14644 2021-05-19 21:36:15 -03:00
Luciano Almeida
0b0279f169 [tests] Add regression tests for SR-14499 2021-05-18 09:09:12 -03:00
Doug Gregor
06dc77ddf3 Revert "[Concurrency] Resyntax 'async let' as 'spawn let'."
This reverts commit 41f42fabbf.
2021-05-06 22:18:36 -07:00
Doug Gregor
41f42fabbf [Concurrency] Resyntax 'async let' as 'spawn let'.
This helps track the proposal.
2021-04-29 23:28:16 -07:00
Evan Wilde
3da0a540eb Update tests
This patch updates all the tests to accept the new error messages.
*Gack* so many things needed cleaning up.
2021-04-24 07:51:18 -07:00
Pavel Yaskevich
2de9053dae [Diagnostics] Filter operators if all their arguments are holes
Restrict filtering in `simplifyAppliedOverloadsImpl` to disable
overload set for operators only, because other calls e.g. regular
functions or subscripts could be filtered on labels and are less
overloaded.

Filtering non-operator calls could also lead to incorrect diagnostics
because first choice could have all sorts of different issues e.g.
incorrect labels and number of parameters.

Resolves: rdar://55369704
2021-04-14 15:44:13 -07:00
Mishal Shah
22f61df98b Use %target-cpu in the tests to support running on Apple Silicon hardware 2021-04-08 23:26:18 -07:00
Evan Wilde
45c81c22e3 Updating tests to verify fix-it placement
Updating the test to verify that we're putting the try fix-its in the
right place.
2021-04-06 09:58:59 -07:00
Doug Gregor
c76dac7155 Banish @asyncHandler to a hidden flag.
We don't want @asyncHandler to be part of the concurrency model, so put
it behind a different flag.
2021-03-25 16:45:21 -07:00
Luciano Almeida
af370f14f8 [test] Add regression tests for SR-14096 2021-03-21 18:30:13 -03:00
Pavel Yaskevich
dde9fa35e8 [ConstraintSystem] Re-activate constraints if, due to incorrect reference, member type has been bound before base type
If member has been bound before the base and the base was
incorrect at that (e.g. fallback to default `Any` type),
then we need to re-activate all of the constraints
associated with this member reference otherwise some of
the constraints could be left unchecked in inactive state.

This is especially important for key path expressions because
`key path` constraint can't be retired until all components
are simplified.

Resolves: SR-13364
Resolves: rdar://66706980
Resolves: rdar://74711236
2021-03-12 15:31:06 -08:00
Kavon Farvardin
74eb1a7ae6 allow property/subscript access expressions for actors in typechecker
We now mark some DeclRefExpr and LookupExprs as implicitly async
during typechecking, depending on whether they appear in a context
that is only performing a read / get operation, and whether they
are cross-actor operations.

also resolves rdar://72403401 by improving the error messages
(no more vague "'await' in async context" when its clearly a call!)
2021-03-04 18:37:32 -08:00
Kavon Farvardin
9342540661 add fix-it to note for "add 'async' to function"
resolves rdar://72313654
2021-02-11 14:44:49 -08:00
Doug Gregor
3c38ffe0ea [Concurrency] await try -> try await
The `try await` ordering is both easier to read and indicates the order
of operations better, because the suspension point occurs first and
then one can observe a thrown error.
2020-12-23 13:21:59 -08:00
Konrad `ktoso` Malawski
7b37554096 [Concurrency] Initial TaskGroup implementation working 2020-12-17 06:05:13 +09:00
Doug Gregor
35acd40b1e +concurrency task groups initial work in progress 2020-12-17 06:05:13 +09:00
Doug Gregor
b7be6cefc7 Merge pull request #35107 from DougGregor/async-let-implicit-try-await
[Concurrency] Make 'await' and 'try' implicit in async let initializer
2020-12-15 20:40:05 -08:00
Doug Gregor
bffc7434fa [Concurrency] Make 'await' and 'try' implicit in async let initializer 2020-12-15 16:15:40 -08:00
Kavon Farvardin
e8dcc979a0 fix-it regression coverage for notes suggesting 'async', '@asyncHandler' and '@GlobalActorType'
Currently, we don't have a fix-it to insert 'async', so I've marked those places
as not expecting a fix-it, until someone goes and implements that (rdar://72313654)
2020-12-14 15:21:27 -08:00
Doug Gregor
18ef1869f3 [Concurrency] Diagnose "try await" with a Fix-It 2020-12-04 00:57:18 -08:00
Doug Gregor
50cdddaf95 [Concurrency] Enable implicit conversion from synchronous -> asynchronous. 2020-12-03 12:44:21 -08:00
Pavel Yaskevich
d7c6c00e04 Merge pull request #34614 from xedin/improvements-to-ambiguity-diags
[Diagnostic] Improve diagnostics for situations with ambiguity caused by conformance requirements
2020-11-09 16:07:11 -08:00
Pavel Yaskevich
66fbdce2f8 [ConstraintSystem] Don't increase a score for conditional requirement failures
Let's consider conditional requirement failure to mean that parent
conformance requirement wasn't satisfied and nothing more, that helps
to disambiguate certain situations and avoid filtering out conditional
failures.

Resolves: rdar://problem/64844584
2020-11-06 12:06:00 -08:00