Skip to content

Commit 6714723

Browse files
committed
Sema: Reject invalid attributes on local variables in result builders
Fixes <rdar://problem/73545981>.
1 parent c0ca9ad commit 6714723

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

lib/Sema/BuilderTransform.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ class BuilderClosureVisitor
288288
unhandledNode = patternBinding;
289289
return;
290290
}
291+
292+
// Also check for invalid attributes.
293+
TypeChecker::checkDeclAttributes(var);
291294
}
292295
}
293296

test/Constraints/result_builder_invalid_vars.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,9 @@ dummy {
4343
@Wrapper var wrappedVar: Int = 123 // expected-error {{closure containing a declaration cannot be used with result builder 'DummyBuilder'}}
4444
()
4545
}
46+
47+
dummy {
48+
@resultBuilder var attributedVar: Int = 123 // expected-error {{@resultBuilder' attribute cannot be applied to this declaration}}
49+
// expected-warning@-1 {{variable 'attributedVar' was never used; consider replacing with '_' or removing it}}
50+
()
51+
}

0 commit comments

Comments
 (0)