Commit Graph

94 Commits

Author SHA1 Message Date
Henrik G. Olsson
cbc0ec3b88 Add -verify-ignore-unrelated where necessary (NFC)
These are tests that fail in the next commit without this flag. This
does not add -verify-ignore-unrelated to all tests with -verify, only
the ones that would fail without it. This is NFC since this flag is
currently a no-op.
2025-10-04 14:19:52 -07:00
Mykola Pokhylets
4aa2847ad6 Fixed some tests
Remaining failures:

DebugInfo/guard-let-scope4.swift
expr/closure/closures.swift
SILGen/capture-transitive.swift
SILGen/dynamic_self.swift
SILGen/unowned-class-bound-generic-parameter.swift
2025-05-19 09:37:03 +02:00
Allan Shortlidge
949a6c68d7 AST/Sema: Retire SemanticAvailableAttr::getVersionAvailability().
Query for availability constraints instead of calling getVersionAvailability().
2025-02-16 07:44:45 -08:00
Mateus Rodrigues
2ff7492fcd Update other tests to handle trailing comma 2024-07-22 10:00:01 -03:00
Anthony Latsis
9017bf77b1 Sema: Improve error messages for super in illegal context 2024-04-18 23:07:14 +03:00
Allan Shortlidge
0096904caa Parse: Diagnose empty version numbers.
The compiler treats version tuples that are all zeros as empty, or the same as
not having a version. Diagnose attempts to specify all-zeroes versions in
attributes and availability queries to prevent surprising behavior.

Resolves rdar://124661151
2024-03-19 18:17:56 -07:00
Doug Gregor
57f431d497 Update more tests for associated types with availability 2024-01-05 13:30:01 -08:00
Doug Gregor
68b367b266 Disable macros-related tests harder 2023-03-29 16:32:32 -07:00
Doug Gregor
30f17940f9 Require the Swift swift parser for a few tests affected by macros 2023-03-29 16:32:32 -07:00
Anthony Latsis
14b70f306b DiagnosticVerifier: Default expected fix-it start line to the diagnostic's 2023-03-08 12:10:27 +03:00
Doug Gregor
7fc7040aad [Macros] Drop special code completions for built-in macros.
We don't need special completion logic for things like `#file` and
`#line` now that they are declared in the standard library. Drop it
and update tests.
2023-03-02 20:34:58 -08:00
Joe Groff
704a4363d7 C++ parser: support borrowing and consuming modifiers.
And adjust contextual parameter modifier parsing in general to be more
properly contextual, so we don't have to reserve `__shared` or `__owned`,
or their successor spellings, as argument labels anymore.
2023-02-28 09:16:45 -08:00
Anthony Latsis
ff7f117025 Gardening: Migrate test suite to GH issues: Parse 2022-09-02 01:44:24 +03:00
Alex Hoppen
e14fa7291f [CS] Don’t fail constraint generation for ErrorExpr or if type fails to resolve
Instead of failing constraint generation by returning `nullptr` for an `ErrorExpr` or returning a null type when a type fails to be resolved, return a fresh type variable. This allows the constraint solver to continue further and produce more meaningful diagnostics.

Most importantly, it allows us to produce a solution where previously constraint generation for a syntactic element had failed, which is required to type check multi-statement closures in result builders inside the constraint system.
2022-07-20 09:46:12 +02:00
Slava Pestov
1bf248e374 Enable parameterized protocols by default, and add new staging flag for parameterized existentials 2022-04-06 17:30:10 -04:00
Varun Gandhi
a1716fe2a6 [Diagnostics] Update compiler diagnostics to use less jargon. (#31315)
Fixes rdar://problem/62375243.
2020-04-28 14:11:39 -07:00
Mattt
d40d47f209 Fix spelling of '@available' in error message "'@availability' attribute cannot be applied to this declaration" (#29760)
* Update DAK_Available name to match @available keyword

Update expected errors for @available attribute tests

* Update available attribute keyword name in DeclAttrKeyword documentation comment
2020-02-11 22:45:38 +00:00
Robert Widmann
5beb6f0f6e Restructure invalid parameter diagnostic
Diagnose the fact that we're missing a colon, not the fact that we're missing a type since that's actually what has gone wrong.
2019-10-24 09:56:02 -07:00
Nathan Hawes
05ef088859 Revert "Remove The Last Vestiges of isInvalid from Parse" 2019-10-22 11:31:07 -07:00
Robert Widmann
dc63923a30 Restructure invalid parameter diagnostic
Diagnose the fact that we're missing a colon, not the fact that we're missing a type since that's actually what has gone wrong.
2019-10-21 15:18:20 -07:00
Rintaro Ishizaki
8768832f24 Revert "Merge pull request #27281 from rintaro/reapply-syntaxparse-genericparam"
This reverts commit 5d3e8d6c83, reversing
changes made to 27e881d97e.
2019-10-14 12:46:31 -07:00
Rintaro Ishizaki
4eadbaa9f6 Revert "Merge pull request #27466 from rintaro/syntaxparse-type"
This reverts commit a4fcd26b38, reversing
changes made to 88ecae4b9a.
2019-10-14 12:19:04 -07:00
Rintaro Ishizaki
6f4dc258f5 Revert "Merge pull request #27544 from rintaro/syntaxparse-attrincomplete"
This reverts commit 071a7134b3, reversing
changes made to dbddb0d89a.
2019-10-14 12:17:27 -07:00
Rintaro Ishizaki
d2971fa1a0 [SyntaxParse] Fix crasher for generic parameter with attributes
It used to crash for:
Attribute without its name (e.g. Foo<@>)
Missing name with attributes (e.g. Foo<@available(*, unavailable)>

- Synthesize identifier token so that the SyntaxParsingContext can
  successfully construct the Attribute syntax.
- Don't throw away the parsed attributes if the parameter name is
  missing. Instead, construct GenericParamater syntax anyway, and handle
  it in ASTGen.
2019-10-04 11:03:23 -07:00
Rintaro Ishizaki
7b31d2b4fb [SyntaxParse] Finish type parsing
- Type attributes
- SIL types
2019-10-01 15:40:10 -07:00
Rintaro Ishizaki
0569cbfb28 Revert "Revert "[SyntaxParse] Parse generic parameter clause and generic where clause""
This reverts commit 1584e87aa7.
2019-09-20 15:26:04 -07:00
Rintaro Ishizaki
1584e87aa7 Revert "[SyntaxParse] Parse generic parameter clause and generic where clause" 2019-09-20 14:02:53 -07:00
Rintaro Ishizaki
f919b2ddd8 [SyntaxParse] Parse generic parameter clause and generic where clause 2019-09-19 23:09:58 -07:00
Sam Lazarus
ede8127adf Test: Add and update tests for allowing var and let as argument labels 2019-04-26 04:08:27 -04:00
Sam Lazarus
2a38b48eea Parse / AST: Allow let / var as argument labels with a warning.
The diagnostic is now a warning and the new message alerts the user that
though it is valid to have let and var as argument label names,
they are interpreted as argument labels, not keywords.
2019-04-26 04:08:01 -04:00
Rintaro Ishizaki
0428adfa1b [Parse/Sema] Diagnose invalid attributes for GenericTypeParamDecl
Previously, invalid attributes were silently accepted and ignored.

https://bugs.swift.org/browse/SR-8202
2018-07-10 20:29:31 +09:00
Rintaro Ishizaki
1e0dd7a209 [Parse/Sema] Diagnose invalid attributes for ParamDecl
Previously, invalid attributes were silently accepted and ignored.

https://bugs.swift.org/browse/SR-8202
2018-07-10 20:29:23 +09:00
Pavel Yaskevich
2f07663265 [Parser] {pre,post}fix operator calls with tuple arguments should implicit parens 2018-07-02 08:56:45 -07:00
Alex Hoppen
bc528237e5 [libSyntax] Adjust tests for improved syntax parsing behaviour 2018-05-22 09:07:56 -07:00
John McCall
7815892a76 Add unique typo corrections to the main diagnostic with a fix-it.
Continue to emit notes for the candidates, but use different text.
Note that we can emit a typo correction fix-it even if there are
multiple candidates with the same name.

Also, disable typo correction in the migrator, since the operation
is quite expensive, the notes are never presented to the user, and
the fix-its can interfere with the migrator's own edits.

Our general guidance is that fix-its should be added on the main
diagnostic only when the fix-it is highly likely to be correct.
The exact threshold is debateable.  Typo correction is certainly
capable of making mistakes, but most of its edits are right, and
when it's wrong it's usually obviously wrong.  On balance, I think
this is the right thing to do.  For what it's worth, it's also
what we do in Clang.
2018-04-07 16:01:39 -04:00
Huon Wilson
e307e54098 [AST] Explicitly track things marked __owned. 2018-03-08 12:36:24 +11:00
Graydon Hoare
81aecb6a54 [Diagnostics] s/may/must/ in 'may not be applied to' 2017-09-29 16:09:23 -04:00
Graydon Hoare
bf42def404 [Diagnostics] s/may/must/ in 'may not have multiple' 2017-09-29 16:09:23 -04:00
Slava Pestov
19fed22872 Parse: Remove redundant diagnostic
We had two slightly different codepaths to diagnose ': class'
in an inheritance clause where it is not supported.

For generic parameters, we would fix the 'class' to 'AnyObject',
but for associated types we didn't do this. Perform the fix in
all cases where it makes sense and remove one of the two
diagnostics.
2017-09-05 21:53:52 -07:00
David Zarzycki
f0b1924a19 [Diags QoI] Avoid premature return in checkOwnershipAttr()
This also removes some dead code, where an early assert() ensures that
'strong' is never passed into the function, but then the function later
tries to handle 'strong'.

Finally, use a switch statement for future proofing.
2017-08-09 13:13:36 -04:00
Robert Widmann
b77f2c147c Parse Shared
Add parser support for __shared and __owned as type attributes.  Also, extend parser diagnostics and tests to account for the new type attributes.
2017-07-23 21:47:25 -07:00
Robert Widmann
43f29399f3 Remove an old diagnostic for 'var' in param position
Using the attribute in this position is a relic from the Swift 2
days, and fixing it required letting invalid code fall through to
Sema instead of being diagnosed in Parse proper.  Treat 'var'
in this position like 'let' by simply offering to remove it
instead of extracting it into a separate variable.
2017-06-29 13:35:59 -07:00
Rintaro Ishizaki
5d478bdb3b [Parse] Allow #if to guard switch case clauses
Resolves:
https://bugs.swift.org/browse/SR-4196
https://bugs.swift.org/browse/SR-2
2017-06-17 10:03:03 +09:00
Huon Wilson
07c5ab8fb2 Implement \ syntax for Swift key paths.
This introduces a few unfortunate things because the syntax is awkward.
In particular, the period and following token in \.[a], \.? and \.! are
token sequences that don't appear anywhere else in Swift, and so need
special handling. This is somewhat compounded by \foo.bar.baz possibly
being \(foo).bar.baz or \(foo.bar).baz (parens around the type), and,
furthermore, needing to distinguish \Foo?.bar from \Foo.?bar.

rdar://problem/31724243
2017-05-01 16:06:15 -07:00
Robert Widmann
39494b2ba2 Rearrange test code for exhaustiveness 2017-04-28 02:06:39 -04:00
Xi Ge
b4cf37bf7d Sema: several improvements on missing switch cases diagnostics. (#8026)
1. Make sure the actions taken by fixits are reflected in diagnostics messages.
2. Issue missing cases diagnostics at the start of the switch statement instead of its end.
3. Use <#code#> instead of <#Code#> in the stub.
2017-03-10 19:32:37 -08:00
Xi Ge
daac020c61 Sema: Reject empty switch statements during type checking so that we can issue fixits to fill the unhandled switch cases. (#7766) 2017-02-25 08:01:13 -08:00
Slava Pestov
4f4e6f6ebf Sema: Remove another workaround and fuzz harder
We used to drop the entire generic parameter list if one of the
entries failed to parse. This caused a problem where the generic
parameters were still available for name lookup, so they had
to be special-cased since there's no generic environment set up
in this case.

Now, keep the parts of the generic parameter list around that
parsed successfully.

When I first made the change, almost a hundred crashers regressed;
now all the underlying issues have been fixed.

The result is that in addition to removing a crappy hack we get
some more mileage out of the compiler_crashers, because stuff like
this now builds a generic environment:

class S<T{...}
2017-02-03 17:02:04 -08:00
Rintaro Ishizaki
42ebd38c29 [Parse] Skip non-case-label statements in switch (#6215) 2016-12-13 03:37:09 +09:00
Rintaro Ishizaki
97b89adab3 [Parse] Remove redundant 'inout' parsing from parseParameterClause 2016-11-29 23:30:59 +09:00