Commit Graph

1614 Commits

Author SHA1 Message Date
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
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
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
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
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
Hamish Knight
272638a30c [test] Add some more known crashers 2025-12-01 09:12:15 +00: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
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
Slava Pestov
819738c83e AST: Rename mapTypeIntoContext() => mapTypeIntoEnvironment(), mapTypeOutOfContext() => mapTypeOutOfEnvironment() 2025-11-12 14:48:19 -05: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
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
ebd97bb3a0 [test] Update a couple of crasher signatures 2025-11-10 10:40:35 +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
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
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
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
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
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
88091da974 [test] Add some more known crashers 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
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
Slava Pestov
69c8d15570 Sema: Fix a fuzzer crash
This test case crashes when prepared overloads are disabled, but passes
when enabled. To avoid messing up tests if we have to turn the flag on
and off, fix the crash.
2025-10-24 16:20:21 -04:00
Hamish Knight
0eb83fea8b [test] Add some more known crashers 2025-10-20 10:14:32 +01:00
Hamish Knight
eb9ae7c2ef [test] Update a couple of crasher signatures 2025-10-20 10:14:32 +01:00
Hamish Knight
4e811c3a88 [test] Merge crasher directories
There is no longer much of a good reason to keep these separate,
merge them.
2025-10-18 12:51:30 +01:00
Doug Gregor
c142205a50 Resolve an old compiler crasher via the new diagnostic formatter
The old diagnostic formatter would crash on some Fix-Its involving
Unicode characters. The new one does not.
2024-02-19 02:48:37 -10:00
Erik Eckstein
dccaa8f01f diagnose duplicated @_cdecl and @_silgen_name function names
Prints a regular error instead of crashing.
The check is done in SILGen, because it's simple. We could also do it earlier, but I don't see a strong reason for this.

rdar://75950093
2021-03-31 13:30:22 +02:00
Anthony Latsis
2133fe27df Sema: Have TypeResolution accept an unbound generic type opener function 2020-07-08 13:39:34 +03:00
Slava Pestov
31a78590a8 ASTMangler: Fix assertion when mangling invalid identifiers
We sometimes need to mangle invalid identifiers, for example when sorting
declarations in EmittedMembersRequest. Make sure this doesn't assert.
2020-06-29 22:17:56 -04:00
Doug Gregor
2f97d24969 Note a fixed compiler crasher 2020-06-04 23:19:47 -07:00
Slava Pestov
c543838854 Sema: Rewrite partial applications into closures
When a method is called with fewer than two parameter lists,
transform it into a fully-applied call by wrapping it in a
closure.

Eg,

Foo.bar => { self in { args... self.bar(args...) } }
foo.bar => { self in { args... self.bar(args...) } }(self)

super.bar => { args... in super.bar(args...) }

With this change, SILGen only ever sees fully-applied calls,
which will allow ripping out some code.

This new way of doing curry thunks fixes a long-standing bug
where unbound references to protocol methods did not work.

This is because such a reference must open the existential
*inside* the closure, after 'self' has been applied, whereas
the old SILGen implementation of curry thunks really wanted
the type of the method reference to match the opened type of
the method.

A follow-up cleanup will remove the SILGen curry thunk
implementation.

Fixes rdar://21289579 and https://bugs.swift.org/browse/SR-75.
2020-03-18 09:29:22 -04:00
Luciano Almeida
7557f29a27 Reverting file location 2019-06-26 17:49:47 -03:00
Luciano Almeida
6331e9a1cd Reverting file location 2019-06-26 17:49:23 -03:00
Luciano Almeida
2ef18488d6 Walking through the expr to set the types and type variables in the constraint system before add convertion constraint 2019-05-27 22:57:56 -03:00
Alexis Laferrière
bddb40dacf GSB: ignore generic types in expandConformanceRequirement
Fixes crashes in 28437-swift-typechecker-validatedecl.swift (from previous commit)
and the compiler crasher 28861-gpdecl-getdepth-generictypeparamdecl-
invaliddepth-parameter-hasnt-been-validated.swift.
2019-04-30 10:43:23 -07:00
Saleem Abdulrasool
149f6b6b81 test: disable test for incorrect behaviour
This test is testing that the verifier aborts on invalid input.
SR-10459
2019-04-11 18:54:02 -07:00