What is the correct syntax to use a static import of a user-defined-attribute?
Context: Attributes can have names that conflict with local variables. It is desired to use the fully-qualified-name of the attribute to get around this.
Example:
import vibe.data.serialization : name, optional;
class ChatCompletionFunctions {
@name("name") // Error: "name" refers to the string, not the attribute @name.
string name;
@name("max-tokens")
int maxTokens;
}
Attempted Fix 1: static imports
static import vibe.data.serialization;
class ChatCompletionFunctions {
@vibe.data.serialization.name("name")
...
}
This produces the error, it seems to be because the @
symbol stops capturing the annotation name at the first dot it encounters.
source/openai/model/ChatCompletionFunctions.d(19,32): Error: unexpected `(` in declarator
Attempted Fix 2: Enclose the entire attribute name in parenthesis.
static import vibe.data.serialization;
class ChatCompletionFunctions {
@(vibe.data.serialization.name)("name")
...
}
This simply gives:
source/openai/model/ChatCompletionFunctions.d(19,34): Error: declaration expected, not `(`
Is static importing of UDAs even supported in the language?