Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 3309 parameter names trait #951

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/idgen.c
Expand Up @@ -324,6 +324,7 @@ Msgtable msgtable[] =
{ "hasMember" }, { "hasMember" },
{ "identifier" }, { "identifier" },
{ "parent" }, { "parent" },
{ "parameterNames" },
{ "getMember" }, { "getMember" },
{ "getOverloads" }, { "getOverloads" },
{ "getVirtualFunctions" }, { "getVirtualFunctions" },
Expand Down
17 changes: 17 additions & 0 deletions src/traits.c
Expand Up @@ -206,6 +206,23 @@ Expression *TraitsExp::semantic(Scope *sc)
StringExp *se = new StringExp(loc, s->ident->toChars()); StringExp *se = new StringExp(loc, s->ident->toChars());
return se->semantic(sc); return se->semantic(sc);
} }
else if (ident == Id::parameterNames)
{
FuncDeclaration *f;
Dsymbol *s = getDsymbol((*args)[0]);
if ((f = s->isFuncDeclaration()) == NULL)
{
error("argument %s is not a function", s->toPrettyChars());
goto Lfalse;
}
Expressions *exps = new Expressions();
TypeFunction *tf = (TypeFunction *) f->type;
if(tf->parameters)
for (size_t i = 0; i < tf->parameters->dim; i++)
exps->push(new StringExp(loc, ((Parameter*) tf->parameters->data[i])->ident->toChars()));
Expression *e = new TupleExp(loc, exps);
return e->semantic(sc);
}
else if (ident == Id::parent) else if (ident == Id::parent)
{ {
if (dim != 1) if (dim != 1)
Expand Down