Commit Graph

570 Commits

Author SHA1 Message Date
Slava Pestov e33a43aa3e Merge pull request #89167 from slavapestov/clean-up-variadic-parameter-requirement-check
Sema: Fix crash when declaring an old-style variadic parameter with nonescaping type
2026-05-18 22:19:08 -04:00
Slava Pestov f05d1cab32 Sema: Fix crash when declaring an old-style variadic parameter with nonescaping type
This is not supported for the same reason you can't have a noncopyable
variadic parameter, but the code was hard-coded to check for copyability
only.

Generalize this to apply the generic signature for Array via the
common code path, and add a custom note to explain why those requirements
are checked in the first place.

Cleaning this up also fixed some fuzzer crashes.

Reported on the forums:
https://forums.swift.org/t/variadic-escapable-arguments-crash-the-compiler/86727/2
2026-05-18 10:49:23 -04:00
Hamish Knight e23410963d [test] Add some more known crashers 2026-05-18 11:19:49 +01:00
Hamish Knight edd6dac0eb [test] Add some more known crashers 2026-05-11 19:56:47 +01:00
Hamish Knight 59390e2ac3 [test] Add some fixed crashers 2026-05-11 19:56:47 +01:00
Hamish Knight 0dabc9f09b [test] Add some more known crashers 2026-05-05 22:17:12 +01:00
Hamish Knight 9e470d0a56 [test] Add some more known crashers 2026-04-27 20:16:44 +01:00
Kavon Farvardin 2fe42bf765 Test: no more crashy, apparently 2026-04-23 08:56:55 -07:00
Hamish Knight de97dc1ccd [test] Add some more known crashers 2026-04-20 15:33:29 +01:00
Pavel Yaskevich 5da31f9d32 [CSSimplify] Handle situations when generic argument mismatch happens in a synthesized argument
If the argument was synthesized by the solver, let's fail. This can
happen when a parameter type is optional and (currently) inference
would try both optional and non-optional bindings for the new
argument which cases a mismatch in one of the conversion cases.

Resolves: https://github.com/swiftlang/swift/issues/88456
Resolves: rdar://174723056
2026-04-15 16:14:05 -07:00
Hamish Knight 4dede5f0bb [test] Add some more known crashers 2026-04-13 21:04:14 +01:00
Hamish Knight fad6851813 [test] Update a couple of crasher signatures 2026-04-13 18:02:27 +01:00
Hamish Knight 7412098038 [test] Add some more known crashers 2026-04-07 10:10:05 +01:00
Hamish Knight 0676703b29 [test] Update a crasher signature 2026-04-07 10:10:05 +01:00
Hamish Knight ee66deaf4f [AST] Use .value() in SpecializedProtocolConformance::getConditionalRequirements
Make sure we're guaranteed to trap if conditional requirements haven't
been computed yet.
2026-04-03 15:03:29 +01:00
Hamish Knight c2dbef1da6 [test] Add some more known crashers 2026-03-30 11:15:17 +01:00
Hamish Knight 2ee44c60cc [test] Update a couple of crasher signatures 2026-03-30 11:15:17 +01:00
Hamish Knight 6bba2bc0f6 [test] Add some more known crashers 2026-03-23 10:49:33 +00:00
Slava Pestov e7a94ee205 AST: Remove TypeBase::hasDependentMember()
I need to free up a bit.
2026-03-21 08:48:47 -04:00
Hamish Knight 040bb30e61 [test] Add some more known crashers 2026-03-16 10:52:04 +00:00
Hamish Knight cd7ca397e3 [test] Update crashers for second frame signature 2026-03-14 11:54:02 +00:00
Hamish Knight de3f8d874c [test] Update a couple of crasher signatures 2026-03-14 11:54:02 +00:00
Hamish Knight f1a1596e9a [test] Add some more known crashers 2026-03-09 10:41:34 +00:00
Hamish Knight 7350671733 [Sema] Catch use-before-declarations in nested closures
Previously we would allow these in Sema and diagnose them in SILGen,
but allowing them in Sema is unsound because it means the constraint
system ends up kicking interface type requests for declarations that
should be type-checked as part of the closure itself. Adjust the
name lookup logic to look through parent closures when detecting
invalid forward references.

For now we don't fallback to an outer result on encountering a
use-before-declaration to preserve the current behavior. I'm planning
on changing that in the next commit though.

rdar://74430478
2026-03-03 21:59:12 +00:00
Hamish Knight e6f651fd5a [test] Add some more known crashers 2026-02-24 09:24:10 +00:00
Hamish Knight 450a3f1a78 [test] Update a couple of crasher signatures 2026-02-24 09:24:10 +00:00
Hamish Knight 9f7eb32bd5 Merge pull request #87351 from hamishknight/add-fixed-crashers
[test] Add some fixed crashers
2026-02-20 01:32:35 +00:00
Hamish Knight 527f6d0cb0 [test] Add some fixed crashers
Add some crashers that I encountered while making some other changes,
ensure we don't regress them.
2026-02-19 20:37:16 +00:00
Hamish Knight bc81852693 [Completion] Disable an assertion for now
We ought to re-enable this once we're able to rollback completion state
when backtracking in the parser.
2026-02-19 10:02:14 +00:00
Hamish Knight 41524f9591 Merge pull request #87253 from hamishknight/completion 2026-02-19 09:02:58 +00:00
Hamish Knight da89f0e530 [CS] Propagate Sendable-dependence into closures
Missed this in my original Sendable-dependence patch, the sendability
of a closure can be dependent if its contextual type is. I'm not
sure this case ever actually matters in practice, but it seems like we
ought to be consistent with the existing logic and not have the
behavior be dependent on whether the dependence is evaluated before or
after the closure is resolved.
2026-02-16 14:37:58 +00:00
Hamish Knight 48872d2dd3 [Completion] Remove old type-checking logic
All expression completions are now solver-based, so we don't need this
anymore.
2026-02-16 11:18:49 +00:00
Hamish Knight 5a78195bd5 [Sema] Avoid lazy type-checking bindings in closures for completion
Completion can kick lazy type-checking for bindings, make sure we
decline to type-check in a closure since bindings cannot be
type-checked independently of their parent closure.
2026-02-16 11:18:49 +00:00
Hamish Knight 4912cd52a7 [CS] Refuse to match error types
We ought to consider making this an assert, but for now let's bail
out of solving.
2026-02-12 11:34:47 +00:00
Hamish Knight 905e8a04c3 [IDE] Avoid erasing opaque replacement types
The erasing we're doing here is only for printing purposes, that
doesn't really matter for the replacement types and avoids running into
a crash where we incorrectly grab the wrong generic signature.
2026-02-12 11:34:47 +00:00
Hamish Knight 8e6bea381c [test] Add some more known crashers 2026-02-09 19:40:55 +00:00
Hamish Knight eb8ead9264 [test] Add some more known crashers 2026-02-02 09:55:30 +00:00
Hamish Knight 87fa86fe47 [test] Update a couple of crasher signatures 2026-02-02 09:55:30 +00:00
Hamish Knight b231d90c68 [test] Add some more known crashers 2026-01-19 11:26:16 +00:00
Hamish Knight 95bd190c54 [test] Add some more known crashers 2026-01-13 18:24:09 -05:00
Hamish Knight 4e950e3591 Avoid loading serialized extensions for nominals in SourceFile
Looking up serialized extensions for a nested nominal type requires
computing its mangled name, which may kick semantic requests. Ensure
we don't do this for nominals in parsed SourceFiles such that we
don't end up kicking this during extension binding.
2026-01-06 15:34:33 +00:00
Hamish Knight 3aaeaefa97 [test] Add some more known crashers 2025-12-08 11:01:59 +00:00
Hamish Knight 148e2121c1 [test] Update a couple of crasher signatures 2025-12-08 11:01:59 +00:00
Kavon Farvardin 12cb3f9a9a Merge pull request #85704 from kavon/suppressed-assoc-types-with-defaults
Sema: introduce SuppressedAssociatedTypesWithDefaults
2025-12-03 23:07:40 -08:00
Kavon Farvardin ab1d83a31b Sema: fix cycle involving protocol extensions
We've had a load-bearing optimization that avoids rebuilding
the generic signature of the protocol extension to avoid a
cycle involving a typealias in the extension that's mentioned
as a requirement in the protocol, for example:

```
public protocol P3 {
  associatedtype A
}

public protocol P4: P3 where A == B {}

extension P4 {
  public typealias B = String
}
```
What was happening is that we're inside a
StructuralRequirementsRequest, so we're performing TypeResolution
in the Structural stage. When we encounter this typealias that's
within a protocol extension, we'd end up accidentally requesting
the interface type of that alias through
`TypeChecker::substMemberTypeWithBase`
(via `aliasDecl->getUnderlyingType()`).

What we should do instead is call `aliasDecl->getStructuralType()`
and skip the substitution during that stage.

There happened to already be code doing this, but it was only
kicking in if the DeclContext `isa<ProtocolDecl>`, which excludes
extensions of a protocol. I see no reason why extensions of a
protocol should be excluded, so I assume it was unintentional.

Thus, the fix boils down to using `DeclContext::getSelfProtocolDecl`
which does include extensions of protocols. With this fix, the
optimization is no longer load-bearing on the example above.

See the history of this hack in f747121080
or rdar://problem/129540617
2025-12-03 08:03:19 -08:00
Hamish Knight 272638a30c [test] Add some more known crashers 2025-12-01 09:12:15 +00:00
Hamish Knight c717e42af4 [test] Add some already-fixed crashers 2025-12-01 09:12:15 +00:00
Hamish Knight bac0856f27 [test] Add a fixed stress tester issue
This is no longer too complex.
2025-12-01 09:12:15 +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