Commit Graph

56 Commits

Author SHA1 Message Date
Anthony Latsis
3222053810 AST: Add a diagnostic group for any syntax diagnostics
Allow users to escalate `any` syntax warnings to errors with
`-Werror ExistentialAny`.
2025-02-12 22:22:10 +00:00
Allan Shortlidge
24f5632ca1 Frontend: Implement optional parsing diagnostics for enabled language features.
Parsing for `-enable-upcoming-feature` and `-enable-experimental-feature` is
lenient by default because some projects need to be compatible with multiple
language versions and compiler toolchains simultaneously, and strict
diagnostics would be a nuisance. On the other hand, though, it would be useful
to get feedback from the compiler when you attempt to enable a feature that
doesn't exist. This change splits the difference by introducing new diagnostics
for potential feature enablement misconfigurations but leaves those diagnostics
ignored by default. Projects that wish to use them can specify `-Wwarning
StrictLanguageFeatures`.
2025-01-15 16:34:32 -08:00
Doug Gregor
63c9882852 Introduce the notion of a warning that is ignored by default, but enabled by -Wwarning/-Werror
As an example, use this for the "`@preconcurrency` on import has no
effect" warning, which is not yet working correctly. This disables it
by default but leaves it in place for our testing.
2025-01-10 09:10:56 -08:00
Anthony Latsis
9ae3cf1034 AST: Delete the DeclarationUnavailableFromAsynchronousContext diagnostic group
This group has not shipped yet and was added mainly to support test
coverage for d56b7df8a9. Now that we have
unit tests for this, delete the group, pending discussion.
2025-01-07 20:29:07 +00:00
Dmitrii Galimzianov
d56b7df8a9 Add DiagGroupID to Diagnostic
This change addresses the following issue: when an error is being wrapped in a warning, the diagnostic message will use the wrapper's `DiagGroupID` as the warning's name. However, we want to retain the original error's group for use. For example, in Swift 5, async_unavailable_decl is wrapped in error_in_future_swift_version. When we print a diagnostic of this kind, we want to keep the `DiagGroupID` of `async_unavailable_decl`, not that of `error_in_future_swift_version`.
To achieve this, we add `DiagGroupID` to the `Diagnostic` class. When an active diagnostic is wrapped in DiagnosticEngine, we retain the original `DiagGroupID`.

For illustration purposes, this change also introduces a new group: `DeclarationUnavailableFromAsynchronousContext`.

With this change, we produce errors and warnings of this kind with messages like the following:

```
global function 'fNoAsync' is unavailable from asynchronous contexts [DeclarationUnavailableFromAsynchronousContext]
global function 'fNoAsync' is unavailable from asynchronous contexts; this is an error in the Swift 6 language mode [DeclarationUnavailableFromAsynchronousContext]
```
2024-12-03 20:12:11 +01:00
Doug Gregor
7ffa5c324d Put warnings about unsafe constructs into a new diagnostic group Unsafe 2024-11-11 17:50:21 -08:00
Dmitrii Galimzianov
aa5e10f8d2 [Diagnostics] DeprecatedDeclaration group 2024-09-25 23:18:25 +02:00
Dmitrii Galimzianov
9e64b873c3 [Diagnostics] Fix typos and flag names 2024-09-10 21:11:36 +02:00
Dmitrii Galimzianov
28883b6654 [Diagnostics] Add -[no-]warning-as-error flags for precise control over warning behavior
This commit adds new compiler options -no-warning-as-error/-warning-as-error which allows users to specify behavior for exact warnings and warning groups.
2024-09-07 01:14:43 +02:00
Holly Borla
466a021caa [Diagnostics] Add an educational note for error_in_future_swift_version. 2024-03-01 12:05:51 -08:00
Anthony Latsis
4cb63c8a0f [NFC] Migrate remnant Jira issue references to GitHub issues 2022-12-04 08:20:34 +03:00
Anthony Latsis
ccaa6707fe Docs: Reattach, rewrite and rename the «associated-type-requirements» educational note 2021-08-30 22:27:13 +03:00
Kavon Farvardin
c0607b345f Revert "Merge pull request #33767 from theblixguy/chore/remove-self-or-associated-type-diagnostic"
The following regression test added for this feature is not passing:

Swift(linux-x86_64) :: decl/protocol/protocols_with_self_or_assoc_reqs_executable.swift

with a compiler crash happening during SILFunctionTransform "Devirtualizer".

Reverting to unblock CI.

This reverts commit f96057e260, reversing
changes made to 3fc18f3603.
2021-08-26 16:46:42 -07:00
Anthony Latsis
fbae8a4fdb Docs: Reattach, rewrite and rename the «associated-type-requirements» educational note 2021-08-16 18:30:23 +03:00
Jevon Mao
9397ee59d5 [Diagnostics] Add educational notes explaining multiple inheritance (#38253)
* Add educational notes for multiple inheritance

* Update edu note by adopting reviewer suggestions

* Update userdocs/diagnostics/multiple-class-inheritance.md

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>

* Added Flyable protocol definition to example

* Apply suggestions from code review

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Use consistent terminology

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Use utensils example as suggested by review

* Update title to Multiple Inheritance

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

* Rename file to match changed name

* Add more objects in protocol construction example

* Apply suggestions from code review

Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>

Co-authored-by: Varun Gandhi <varun_gandhi@apple.com>
Co-authored-by: Xiaodi Wu <13952+xwu@users.noreply.github.com>
2021-08-01 08:06:38 -04:00
jiaren wang
c5de1f0800 [SR-14824] Improve diagnostic for multi-statement closures instead of saying "too complex closure return type" 2021-06-30 14:36:38 +08:00
Xiaodi Wu
ae35835008 [Docs] Edits for educational note on PATs (#33736)
* [Docs] Minor edits for educational note on PATs

* Adopt reviewer feedback on wording

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>

* Revert a capitalization change

* [Docs] Further revisions based on reviewer feedback for educational note on PATs

Co-authored-by: Owen Voorhees <owenvoorhees@gmail.com>
2021-03-19 23:46:33 -04:00
Doug Gregor
6d41524fe6 [SE-0289] Finish renaming source code, tests to "result builders" 2020-10-20 22:18:51 -07:00
Doug Gregor
0d568a93d4 [SE-0289] Update diagnostics & many other strings to "result builders" 2020-10-20 21:44:09 -07:00
Doug Gregor
6a40a3a8aa [SE-0289] Add support for @resultBuilder.
"Function builders" are being renamed to "result builders". Add the
corresponding `@resultBuilder` attribute, with `@_functionBuilder` as
an alias for it, Update test cases to use @resultBuilder.
2020-10-20 13:24:51 -07:00
Doug Gregor
25cd671ed5 [Code completion] Test and fix 'static func' for function builder methods. 2020-09-16 15:12:12 -07:00
Doug Gregor
591c8cddec [Function builders] Add an educational note on the build* functions.
Introduce an educational note with a synopsis of the build* function
declarations one can add to a function builder, and associate it with
the diagnostics indicating incorrect or missing build* functions.
2020-09-16 14:01:28 -07:00
Xiaodi Wu
cd3440e6b0 Merge pull request #33832 from xwu/existential-edu-part-2
[docs] Rework educational note on protocol type non-conformance, part 2
2020-09-08 20:07:58 -04:00
Xiaodi Wu
7f169103da [docs] Drop a word based on reviewer feedback 2020-09-08 12:40:33 -04:00
Xiaodi Wu
df0117e9cb [docs] Address typo in trailing closure education note 2020-09-07 07:08:06 -04:00
Xiaodi Wu
4103cb8a35 [docs] Restore original wording in two places about trailing closure matching 2020-09-06 20:30:02 -04:00
Xiaodi Wu
680682fc53 [docs] Update educational note for accuracy about Error requirements 2020-09-06 16:51:51 -04:00
Xiaodi Wu
14aaa2eb41 [docs] Minor revision of trailing closure matching edu note 2020-09-06 16:38:04 -04:00
Xiaodi Wu
b1c49514f2 [userdocs] Flesh out alternatives/workarounds for protocol type non-conformance 2020-09-06 15:00:25 -04:00
Xiaodi Wu
dee1b9bf1f Merge pull request #33737 from xwu/nominal-edu
[Docs] Revise wording for nominal types educational note
2020-09-03 16:45:37 -04:00
Xiaodi Wu
8229f71a50 Add a reference to TSPL 2020-09-01 00:08:37 -04:00
Xiaodi Wu
e34a065c7e Align error capitalization and make a minor rewording 2020-09-01 00:00:53 -04:00
Xiaodi Wu
335ae5ffc2 Incorporate reviewer feedback 2020-08-31 23:57:34 -04:00
Xiaodi Wu
33e0b96639 [Docs] Revise wording for nominal types educational note 2020-08-31 23:49:45 -04:00
Xiaodi Wu
fb09435293 [Docs] Rework educational note on protocol type non-conformance 2020-08-31 22:16:31 -04:00
Owen Voorhees
bacc96b3ef Add an educational note explaining SE-0286 changes
Apply suggestions from code review

Co-authored-by: Ben Rimmington <me@benrimmington.com>

Reword explanation of pre-5.3 behavior

Associate SE-0286 note with warning diagnostic
2020-07-29 21:14:43 -07:00
Owen Voorhees
22289b0bb2 Merge pull request #32231 from owenv/opaque-note
[EduNotes] Explain some opaque type diagnostics
2020-07-02 22:28:06 -07:00
Owen Voorhees
c69baa8731 [EduNotes] Explain some opaque type diagnostics 2020-07-01 21:04:16 -07:00
Onyekachi Ezeoke
38e2998e50 implement feedback changes 2020-07-01 04:04:03 +01:00
Onyekachi Ezeoke
42b9b48a06 update educational notes 2020-06-30 22:59:16 +01:00
Onyekachi Ezeoke
cbdb27464e add protocol self conformance exception note 2020-06-27 05:48:11 +01:00
Onyekachi Ezeoke
53b4ce0034 fix confusing protocol diagnostic
- update the diagnostic error message
- add educational notes
2020-06-27 05:48:11 +01:00
Owen Voorhees
6c646ec1fd Merge pull request #31649 from owenv/ephemeral-edu-notes
[Diagnostics] Add an edu note explaining @_nonEphemeral diags
2020-05-11 23:54:42 -05:00
Owen Voorhees
792fb87da5 [Diagnostics] Add an edu note explaining @_nonEphemeral diags 2020-05-11 13:05:12 -07:00
Zhiyu Zhu/朱智语
563c44f154 Fix typo in edu note on StringInterpolationProtocol 2020-05-10 21:42:13 -04:00
Zev Eisenberg
bf5ff50e8d Add syntax highlighting for GitHub. 2020-04-22 18:26:07 -04:00
Owen Voorhees
68530acb1d Add an edu note explaining StringInterpolationProtocol requirements 2020-04-20 14:41:08 -07:00
Owen Voorhees
cfbfadfb43 [Gardening] Standardize edu note markdown headers 2020-03-18 14:03:52 -07:00
swift-ci
3982bb4af7 Merge pull request #28612 from owenv/terminal_md_viewer 2020-03-12 18:55:45 -07:00
Owen Voorhees
72fba7db8a Merge pull request #30153 from owenv/protocol-can-only-be-used-as-a-constraint-because-it-has-self-or-associated-type-requirements-oh-no
[Diagnostics] Add edu note explaining limitations of protocols with assoc. type reqs.
2020-03-10 14:48:39 -07:00