Skip to content

Commit 546e336

Browse files
fixed: interpolation not being warned within a trailing closure
1 parent 2cbce17 commit 546e336

File tree

4 files changed

+6
-4
lines changed

4 files changed

+6
-4
lines changed

Sources/HTMLKitParse/ParseData.swift

+3-2
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ extension HTMLKitUtilities {
169169
}
170170
}
171171
}
172-
if let statements = context.expansion.trailingClosure?.statements {
172+
if let statements = context.trailingClosure?.statements {
173173
var c = context
174-
c.expansion.trailingClosure = nil
174+
c.trailingClosure = nil
175175
for statement in statements {
176176
switch statement.item {
177177
case .expr(let expr):
@@ -259,6 +259,7 @@ extension HTMLKitUtilities {
259259
if let expansion = expr.macroExpansion {
260260
var c = context
261261
c.expansion = expansion
262+
c.trailingClosure = expansion.trailingClosure
262263
c.arguments = expansion.arguments
263264
switch expansion.macroName.text {
264265
case "html", "anyHTML", "uncheckedHTML":

Sources/HTMLKitParse/extensions/HTMLElementValueType.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ extension HTMLElementValueType {
3131
return nil
3232
}
3333
var c = context
34-
c.expansion.trailingClosure = function.trailingClosure
34+
c.trailingClosure = function.trailingClosure
3535
c.arguments = function.arguments
3636
switch key {
3737
case "a": return get(c, a.self)

Sources/HTMLKitUtilities/HTMLExpansionContext.swift

+2
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public struct HTMLExpansionContext: @unchecked Sendable {
1515
#if canImport(SwiftSyntax) && canImport(SwiftSyntaxMacros)
1616
public let context:MacroExpansionContext
1717
public var expansion:MacroExpansionExprSyntax
18+
public var trailingClosure:ClosureExprSyntax?
1819
public var arguments:LabeledExprListSyntax
1920
#endif
2021

@@ -50,6 +51,7 @@ public struct HTMLExpansionContext: @unchecked Sendable {
5051
) {
5152
self.context = context
5253
self.expansion = expansion.as(ExprSyntax.self)!.macroExpansion!
54+
trailingClosure = expansion.trailingClosure
5355
self.ignoresCompilerWarnings = ignoresCompilerWarnings
5456
self.encoding = encoding
5557
self.key = key

Tests/HTMLKitTests/InterpolationTests.swift

-1
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,6 @@ extension InterpolationTests {
343343
}
344344

345345
@Test func closureInterpolation() {
346-
// TODO: fix | where are the warning diagnostics?
347346
let bro:String = "bro"
348347
let _:String = #html {
349348
div {

0 commit comments

Comments
 (0)