8060 Commits

Author SHA1 Message Date
Slava Pestov
a381b1d954 Merge pull request #85968 from slavapestov/tests-12-10-2025
Add some regression tests
2025-12-12 18:05:28 -05:00
Kathy Gray
472937e57d Merge pull request #85591 from kathygray-pl/kathy/diagnosticProperty
[Diagnostics] Increase possibility for missed property diagnostic
2025-12-12 16:09:12 +00:00
Ben Barham
b8e3e4b7b2 Merge pull request #85966 from bnbarham/disable-userdoc-freebsd
[Test] Disable userdoc validation on freebsd
2025-12-12 08:00:29 +10:00
Kathy Gray
fde49b8847 Diagnostics : Increase possibility for missed property diagnostic
Impact for an unknown property access was frequently higher than other options
on ambiguous selections, by 3 to 5 points, causing fix selections that were
farther away and frequently noted to be in accurate. This commit lowers the
impact to be in a similar range to other fixes and this causes property accesses
to be selected more proprotionaly.

In the existing test suite, this changed the diagnostic only in the case of
protocol composition, which was also discovered to be a flawed binding lookup.

Tests added for the property lookup, tests updated for protocol composition
(Including correcting a likely error in a test specification)
2025-12-11 16:08:22 +00:00
Slava Pestov
a0927392f3 Add some regression tests 2025-12-10 18:49:41 -05:00
Ben Barham
92070a655d [Test] Disable userdoc validation on freebsd
Currently failing to find Foundation when running
`generate-doc-index.swift`. This really only needs to run on a single
platform anyway, so let's just disable it from freebsd for now.
2025-12-11 09:41:44 +10:00
Pavel Yaskevich
2c9092486e Merge pull request #85939 from xedin/rdar-159408715
[Diagnostics] Don't attempt to synthesize arguments when destructurin…
2025-12-10 06:49:02 -08:00
Hamish Knight
28d637625a Merge pull request #85928 from hamishknight/overrun
[test] Add a couple more unterminated string delimiter test cases
2025-12-10 14:01:12 +00:00
Slava Pestov
3dcd9bb011 Merge pull request #85938 from slavapestov/12-year-old-fixme-strikes-back
Sema: Tighten ridiculous disambiguation hack for overloaded type declarations
2025-12-10 06:53:43 -05:00
Slava Pestov
6701e5b39b Sema: Tighten ridiculous disambiguation hack for overloaded type declarations
We noticed that a project failed to build with prepared overloads enabled,
but built successfully with prepared overloads disabled.

It turns out that the code clearly should never have been accepted in the
first place, because the type checker was making an arbitrary choice between
two nominal type declarations with the same name.

Further inspection revealed this was because of a FIXME added in 2013 which
was far too broad. Tighten up the logic here to only disambiguate if at least
one of the two declarations is a type alias, and it has the same underlying
type as the other one. A choice between unrelated nominal type declarations
should always be ambiguous.

This still isn't perfect, because we might have two generic type aliases
that are referenced in both solutions with different substitution maps,
in which case we will still erroneously pick the first one. But this
is better than the old logic, at least.

Fixes rdar://165863775.
2025-12-09 22:48:12 -05:00
Pavel Yaskevich
1f887202e1 [Diagnostics] Don't attempt to synthesize arguments when destructuring a single tuple argument results in an overrun
If arguments are represented by a single tuple it's possible
that the issue is not about missing parameters but instead
about tuple destructuring. Fix `fixMissingArguments` to check for
overruns after destructuring and stop if that produces more
arguments then parameters because such situations are better
diagnosed as a general conversion failure rather than a missing
argument(s) problem.

Resolves: rdar://159408715
2025-12-09 16:52:41 -08:00
Slava Pestov
5e952e9b22 Merge pull request #85902 from slavapestov/csbindings-cleanups
Sema: A few more simple CSBindings cleanups
2025-12-09 18:29:53 -05:00
Ben Barham
8e06293dca Merge pull request #85875 from bnbarham/fix-up-userdocs
Fix up the userdocs index
2025-12-10 08:28:11 +10:00
Hamish Knight
d9222877e0 [test] Add a couple more unterminated string delimiter test cases 2025-12-09 21:02:55 +00:00
Hamish Knight
20bee09dc9 Merge pull request #85889 from hamishknight/overrun
[Parse] Fix buffer overrun in `advanceIfMultilineDelimiter`
2025-12-09 20:26:24 +00:00
Hamish Knight
0a8a3bc753 Merge pull request #85895 from hamishknight/fuzzy
[test] Add some more known crashers
2025-12-09 09:21:59 +00:00
Slava Pestov
0fabf82ace Sema: Fix assert failure with non-representative type variable in contractEdges() 2025-12-08 10:12:12 -05: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
Hamish Knight
b8a8a84615 [test] Remove a duplicate test 2025-12-08 11:01:59 +00:00
Pavel Yaskevich
8ac826b9ae [Tests] NFC: Restrict new SwiftUI to macOS
Frontend invocation targets macOS so attempting it on simulators
results in failures different from intended "too complex".
2025-12-07 15:44:26 -08:00
Hamish Knight
0068438385 [Parse] Fix buffer overrun in advanceIfMultilineDelimiter
Make sure we don't scan off the end of the buffer, and scan for the
delimiter before attempting the lookahead.
2025-12-07 20:05:43 +00:00
Slava Pestov
8da3b62d7b Merge pull request #85293 from slavapestov/too-complex-source-loc
Sema: Fix source location bookkeeping for 'reasonable time' diagnostic
2025-12-07 01:26:04 -05:00
Slava Pestov
d8cf185a13 Sema: Fix source location bookkeeping for 'reasonable time' diagnostic
We already had bookkeeping to track which statement in a multi-statement
closure we were looking at, but this was only used for the 'reasonable time'
diagnostic in the case that we hit the expression timer, which was almost
never hit, and is now off by default. The scope, memory, and trial limits
couldn't use this information, so they would always diagnose the entire
target being type checked.

Move it up from ExpressionTimer to ConstraintSystem, so that we get the
right source location there too. Also, factor out some code duplication
in BuilderTransform to ensure we get the same benefit for result builders
applied to function bodies too.
2025-12-06 20:31:08 -05:00
Ben Barham
b29a0a9b3d Fix up the userdocs index
A few docs weren't added to the index, re-run the generation and fix the
test to actually run in order to catch future issues.
2025-12-06 10:18:19 +10: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
Becca Royal-Gordon
5c2fe422fb Merge pull request #85517 from beccadax/mod-squad-bound-by-its-word
Don’t repeat lookup work that may not round-trip
2025-12-03 20:40:07 -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
Mike Ash
0b4ae4d886 Merge pull request #85462 from mikeash/remote-mirror-function-type-global-actor-fix
[Reflection] Improve size computation for remote type metadata reading.
2025-12-03 10:53:30 -05: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
Mike Ash
d6fc306b16 [Reflection] Improve size computation for remote type metadata reading.
Take advantage of the ability to iterate over TrailingObjects when computing the size of certain kinds of type metadata. This avoids the occasional issue where a new trailing object is added to a type, the remote metadata reader isn't fully updated for it, and doesn't read enough data. This change fixes an issue with function type metadata where we didn't read the global actor field.

Not all type metadata is amenable to this, as some don't use TrailingObjects for their trailing data (e.g. various nominal types) and extended existentials need to dereference their Shape pointer to determine the number of TrailingObjects, which needs some additional code when done remotely. We are able to automatically calculate the sizes of Existential and Function.

rdar://162855053
2025-11-21 19:55:32 -05:00
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
Becca Royal-Gordon
b9747b77da Don’t repeat lookup work that may not round-trip
When a DeclRefTypeRepr is bound to a known declaration, the exact DeclNameRef used to create it is erased. This means that we no longer know exactly which module selector was used in the source code, so repeating the lookup with the same instance might produce different results.

Avoid this problem by reusing the bound decl instead of trying to look up the same declaration again.

Fixes rdar://164647850.
2025-11-15 19:16:12 -08: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