Skip to content

Commit 1340b0a

Browse files
committed
Update for #SwiftSettings
1 parent 3029caa commit 1340b0a

File tree

1 file changed

+39
-4
lines changed

1 file changed

+39
-4
lines changed

proposals/0000-swift-settings.md

+39-4
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ public struct SwiftSetting {
155155
}
156156
```
157157

158-
`#SwiftSettings` will expand to an empty string and is used only for syntactic
158+
`#SwiftSettings` will expand to an empty string and is used only for its syntax
159159
and documentation in the IDE.
160160

161161
`SwiftSetting` is a resilient struct that cannot be constructed without a
@@ -211,6 +211,20 @@ restrictions, we expect that any feature that wants to be supported by
211211
and source stability impacts of adding support to `#SwiftSettings`. At minimum,
212212
the feature must obey the above requirements.
213213

214+
Each argument can be passed to `#SwiftSettings` exactly once. Otherwise, an
215+
error will be emitted:
216+
217+
```swift
218+
#SwiftSetting(
219+
.defaultIsolation(MainActor.self),
220+
.defaultIsolation(nil) // Error!
221+
)
222+
223+
#SwiftSetting(
224+
.defaultIsolation(MainActor.self) // Error!
225+
)
226+
```
227+
214228
If a command line option is set to different values at the module and file
215229
level, the setting at the file level will take precedence.
216230

@@ -244,7 +258,7 @@ extension SwiftSetting {
244258
public init() { fatalError("Cannot construct a DiagnosticGroup") }
245259
}
246260

247-
public static func warningsAsErrors(_ diagnosticGroup: DiagnosticGroup) -> SwiftSetting { ... }
261+
public static func warningsAsErrors(_ diagnosticGroup: DiagnosticGroup...) -> SwiftSetting { SwiftSetting() }
248262
}
249263
```
250264

@@ -414,8 +428,29 @@ compiler settings since we are attempting to specifically support compiler
414428
settings that semantically can have file wide implications. If we wanted to
415429
support push/pop of compiler settings it would involve different trade-offs and
416430
restrictions on what settings would be able to be used since the restrictions
417-
would necessarily need to be greater.
431+
would necessarily need to be greater. As an example, we could never allow for
432+
433+
### Extending SwiftSetting to include parsing options
434+
435+
We could make it so that parsing `#SwiftSetting` is done directly in the parser
436+
when we parse part of the macro grammar. This would work by evaluating the
437+
`#SwiftSetting` from its syntax and performing our pattern matching at parse
438+
time instead of at type checker time. We would then not create an AST for
439+
`#SwiftSetting`. This current proposal is compatible with the parsing approach
440+
since in such a case, `#SwiftSetting` would never show up at AST time.
441+
442+
### Adding support for Strict Memory Safety
443+
444+
We could also in the future add support to #SwiftSettings for Strict Memory
445+
Safety. This is not technically needed in the short term.
446+
447+
### Adding the ability to opt out of module-level flags like warningsAsErrors
448+
449+
We could add support for turning off features like warningsAsErrors at the file
450+
level. This would involve adding a new `disableWarningsAsErrors` method onto
451+
`SwiftSetting`.
418452

419453
## Acknowledgments
420454

421-
TODO
455+
I would like to thank Holly Borla, Doug Gregor, Konrad Malawski and the rest of
456+
Swift Evolution for feedback on this proposal.

0 commit comments

Comments
 (0)