@@ -155,7 +155,7 @@ public struct SwiftSetting {
155
155
}
156
156
```
157
157
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
159
159
and documentation in the IDE.
160
160
161
161
` 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
211
211
and source stability impacts of adding support to ` #SwiftSettings ` . At minimum,
212
212
the feature must obey the above requirements.
213
213
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
+
214
228
If a command line option is set to different values at the module and file
215
229
level, the setting at the file level will take precedence.
216
230
@@ -244,7 +258,7 @@ extension SwiftSetting {
244
258
public init () { fatalError (" Cannot construct a DiagnosticGroup" ) }
245
259
}
246
260
247
- public static func warningsAsErrors (_ diagnosticGroup : DiagnosticGroup) -> SwiftSetting { ... }
261
+ public static func warningsAsErrors (_ diagnosticGroup : DiagnosticGroup... ) -> SwiftSetting { SwiftSetting () }
248
262
}
249
263
```
250
264
@@ -414,8 +428,29 @@ compiler settings since we are attempting to specifically support compiler
414
428
settings that semantically can have file wide implications. If we wanted to
415
429
support push/pop of compiler settings it would involve different trade-offs and
416
430
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 ` .
418
452
419
453
## Acknowledgments
420
454
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