Commit Graph

8026 Commits

Author SHA1 Message Date
Hamish Knight
4992c7ab8b Merge pull request #85538 from hamishknight/binding-fixes
[Sema] A couple of binding-related crasher fixes
2025-11-18 19:48:25 +00:00
Hamish Knight
86f8e22494 [test] Add some more known crashers 2025-11-17 13:09:17 +00:00
Hamish Knight
4cc9ea5ed4 [test] Update some crasher signatures 2025-11-17 13:09:17 +00:00
Hamish Knight
ff833daab4 [ASTScopes] Remove ErrorExpr check from condition scope expansion
This appears unnecessary and incorrectly meant the ErrorExpr would
be placed outside the condition, meaning we could find the binding
in its own initializer.
2025-11-17 13:07:36 +00:00
Hamish Knight
1923037502 [CS] Invalidate unresolved variables in ExprPatterns early
Make sure we invalidate when we initially visit the ExprPattern to
ensure that we don't run into issues when generating constraints for
a `where` clause before the constraints for the ExprPattern. We ought
to change the constraint generation there to use a conjunction to
ensure that the pattern is solved before the `where` clause, but I
want to keep this as a quick low risk fix that we can cherry-pick. I'll
switch it to a conjunction in a follow-up.
2025-11-17 13:07:36 +00:00
Hamish Knight
e7f5ca954b [Sema] Better handle recovery for structurally invalid ReturnStmts
Make sure we preserve the result expression for an out-of-place
`return`, or a non-`nil` result in an initializer. This ensures we
can still provide semantic functionality from them and fixes a crash
where we would fail to type-check a binding.
2025-11-17 13:07:36 +00:00
Hamish Knight
61a5ae8e01 [CS] Eagerly bind hole in recordInvalidNode
We know this is where the issue is so we can immediately bind to a hole,
ensuring we don't produce unnecessary downstream diagnostics from
things we can't infer.
2025-11-16 11:47:21 +00:00
Hamish Knight
3f4c3b542f [CS] Fix a couple of missing error paths
Make sure we set `hadError` other we'll fail to invalidate the target.
2025-11-14 15:39:49 +00:00
Pavel Yaskevich
80e6cbf3ef Merge pull request #85460 from xedin/replace-checkconformancewithoutcontext-with-conformstoknownprotocol
[CSOptimizer] Use `conformsToKnownProtocol` to check whether paramete…
2025-11-13 07:40:36 -08:00
Slava Pestov
819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05:00
Hamish Knight
e2287b6312 Merge pull request #85449 from hamishknight/whats-the-catch
[Sema] Skip type-checking catch bodies when computing the bound error type
2025-11-12 19:34:45 +00:00
Pavel Yaskevich
62a917800d [CSOptimizer] Use conformsToKnownProtocol to check whether parameter conforms to ExpressibleBy{Array, Dictionary}Literal
The existing check is no-op because it would never produce a null for
`paramType` under the conditions in `else` branch. A better
API it use here is `conformsToKnownProtocol` just like in other cases.
2025-11-12 10:51:54 -08:00
Pavel Yaskevich
4d8d719b92 Merge pull request #85406 from naveen-seth/fix-ambiguous-trailing-closure-init
[Sema] Fix crash when diagnosing ambiguous trailing closure inits
2025-11-12 10:03:46 -08:00
Hamish Knight
14608cb059 [Sema] Skip type-checking catch bodies when computing the bound error type
Make sure we only ever type-check the `do` body of a `do-catch`
statement when lazily type-checking the bound error type, which we can
do for completion.

rdar://164481242
2025-11-11 23:04:30 +00:00
naveen-seth
a20879b7cc Move new test to validation-test/compiler_crashers 2025-11-11 17:24:37 +01:00
naveen-seth
d07ea18b55 Mark validation test as fixed 2025-11-11 00:43:01 +01:00
Hamish Knight
1b5e1db05d [test] Add some more known crashers 2025-11-10 10:40:35 +00:00
Hamish Knight
0c553cabee [test] Add some not-yet-crashing crashers
These would crash with an assertion I'm planning on adding, make sure
I fix them before adding the assert.
2025-11-10 10:40:35 +00:00
Hamish Knight
ebd97bb3a0 [test] Update a couple of crasher signatures 2025-11-10 10:40:35 +00:00
Hamish Knight
fe54011bcb Merge pull request #85393 from hamishknight/add-null-check
[CS] Add null check for ParameterList in `findFavoredChoicesBasedOnArity`
2025-11-08 03:44:10 +00:00
Hamish Knight
b26b0b783e [CS] Add null check for ParameterList in findFavoredChoicesBasedOnArity
rdar://164116965
2025-11-07 22:17:33 +00:00
Hamish Knight
0feacec63b [CS] Fix an over-eager assert
We can in fact have placeholders here if the type is bound to a hole.
2025-11-07 16:23:30 +00:00
Hamish Knight
f205f469a9 [CS] Replace error type with hole for projected value
Missed this in my previous patch, make sure we replace an error with
a hole if necessary.
2025-11-05 20:29:15 +00:00
Hamish Knight
dad263728f Merge pull request #85193 from hamishknight/wrapping-paper
[CS] A couple of property wrapper fixes
2025-11-05 19:51:51 +00:00
Hamish Knight
0f58eb2104 [Sema] Fix and cleanup distributed id/actorSystem synthesis (#85245) 2025-11-04 10:17:05 +09:00
Hamish Knight
260d10f6b8 [CS] Fix a couple of fixPropertyWrapperFailure crashers
Make sure we query the constraint system for a type if we have a local
property wrapper in a closure to avoid kicking interface type
computation outside the closure, and make sure we map into context if
we need to.
2025-11-04 00:56:01 +00:00
Hamish Knight
c1bf9f4fb1 [CS] Invalidate auxiliary vars in markInvalid
And make sure we mark any PatternBindingDecl entries as having
been checked to avoid re-checking. This fixes a crash where we could
attempt to re-check a property wrapper to compute its backing type.
2025-11-04 00:56:00 +00:00
Hamish Knight
e0de61caa4 Merge pull request #85135 from hamishknight/lazy-fix
[AST] Avoid exposing `lazy` local storage var to name lookup
2025-11-04 00:53:31 +00:00
Kathy Gray
feebe6aa49 Merge pull request #85235 from kathygray-pl/requirementMachine: Fix crash on pack
Requirement Machine: Fix crash on pack + tuple type
2025-11-03 13:49:34 +00:00
Anthony Latsis
b0548203e2 [test] Clean up a few more nocapture in tests 2025-11-02 08:28:54 +00:00
Kathy Gray
d68a7a7ef0 Requirement Machine: Fix an issue with pack expansion + tuple type crashes
Support pack expansion types in term rewriting, maintaining shape invariants and not
throwing assertions unnecessarily.

Additional tests added for an inifinite case and a concrete case.
2025-10-31 17:53:59 +00:00
Slava Pestov
2ba29d3806 Merge pull request #85183 from slavapestov/fix-issue-85034
Sema: Don't coerce subexpression of 'try' to rvalue
2025-10-29 07:20:27 -04:00
Slava Pestov
8fd7a1db86 Sema: Fix CSGen for ForceTryExpr 2025-10-28 19:56:32 -04:00
Slava Pestov
f014a9aeec Sema: Don't coerce subexpression of 'try' to rvalue
The change in 8ab8b2e3e9, was too
broad. We want to coerce the subexpression of `try!` to an rvalue,
but not the subexpression of a `try`.

If the subexpression of a `try` becomes an rvalue even though the
type of the parent expression is an lvalue, we can end up with
infinite recursion in coerceToType(), as demonstrated by the
test case.

Fixes https://github.com/swiftlang/swift/issues/85034.
2025-10-28 19:21:35 -04:00
Slava Pestov
97f7efd257 Sema: rdar://r78102266 was a SILGen crash so fix the test to pass -emit-silgen 2025-10-28 19:21:01 -04:00
Hamish Knight
949bb3db9b Merge pull request #85173 from hamishknight/no-asan
[test] Avoid running crasher test cases on ASan
2025-10-28 21:28:00 +00:00
Konrad `ktoso` Malawski
fc168a0773 [Distributed] Don't crash when 'open' distributed actor is declared (#85170) 2025-10-28 23:30:06 +09:00
Hamish Knight
29e1fddaa9 [test] Avoid running crasher test cases on ASan 2025-10-28 11:34:19 +00:00
Pavel Yaskevich
ca0491ac77 Merge pull request #85151 from xedin/rdar-161419917
[CSOptimizer] Update unary call favoring to include resolved member r…
2025-10-28 18:06:00 +09:00
Hamish Knight
41acdebce4 Merge pull request #85150 from hamishknight/fuzzy
[test] Add some more known crashers
2025-10-27 17:51:25 +00:00
Hamish Knight
b47ab91547 Merge pull request #85149 from hamishknight/fail-n-bail
[CS] Propagate CSApply failures in a few more places
2025-10-27 16:58:03 +00:00
Pavel Yaskevich
e1a6077117 [CSOptimizer] Update unary call favoring to include resolved member references
Update special favoring logic for unlabeled unary calls to support
non-overloads member references in argument positions.

The original hack missed a case where a type of a member is known
in advance (i.e. a property without overloads) because there as
another hack (shrink) for that.

This helps in situations like `Double(x)` where `x` is a property
of some type that is referenced using an implicit `self.` injected
by the compiler.

Resolves: rdar://161419917
2025-10-27 18:22:37 +09:00
Hamish Knight
88091da974 [test] Add some more known crashers 2025-10-27 08:49:51 +00:00
Hamish Knight
f67c54d24c [test] Update a couple of crasher signatures 2025-10-27 08:49:51 +00:00
Hamish Knight
05e3d15955 [CS] Propagate CSApply failures in a few more places
We had some cases where we weren't propagating failures to apply the
solution, and as such weren't invalidating the resulting AST. Fix up
these cases.
2025-10-26 14:49:17 +00:00
Hamish Knight
62f0926d25 [CS] Invalidate nested unresolved VarDecls when ignoring completion argument
Make sure we set types for any nested VarDecls in UnresolvedPatternExprs
to ensure we don't crash when attempting to solve the body.
2025-10-26 12:33:29 +00:00
Hamish Knight
55ebd0774e [AST] Avoid exposing lazy local storage var to name lookup
We already reject attempts to reference this for `lazy` properties.
For `lazy` locals let's just not expose it to name lookup to begin
with. This ensures we don't attempt to prematurely kick the interface
type computation for the var, fixing a couple of crashers.
2025-10-25 15:07:11 +01:00
nate-chandler
b4777083b0 Merge pull request #85128 from nate-chandler/rdar162922634
[CastOptimizer] Use TypeConverter to lower type.
2025-10-24 23:47:03 -07:00
Slava Pestov
3b1960eb9a Merge pull request #85016 from slavapestov/prepared-fuzz
Sema: Fix a fuzzer crash
2025-10-24 21:46:34 -04:00
Nate Chandler
ef6bd64e7f [CastOptimizer] Use TypeConverter to lower type.
rdar://162922634
2025-10-24 15:34:09 -07:00