Why must conditional local functions be static? #7527
Unanswered
colejohnson66
asked this question in
Q&A
Replies: 1 comment 4 replies
-
I want to say that it's probably more related to preventing capturing, which |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
To conditionally compile an invocation of a function, we can tag it with the
[Conditional(...)]
attribute. These functions can be static or not, and it'll work. However, if the function is "local", it must be static. Why?Without
static
on the local function form, I get the following error:Why? Local functions are lowered to normal ones, just with unspeakable names. In this case, that's
<Main>g__ConditionalFunction|0_0
. And once they're no longer local, they're no different from normal functions that can be conditional. What's the reasoning for this discrepancy?Beta Was this translation helpful? Give feedback.
All reactions