-
-
Notifications
You must be signed in to change notification settings - Fork 701
Fix Issues 23408 and 23403 - __FUNCTION__ does not resolve properly #14549
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3369,6 +3369,17 @@ extern (C++) final class StructLiteralExp : Expression | |
| return Expression.toLvalue(sc, e); | ||
| } | ||
|
|
||
| override Expression resolveLoc(const ref Loc loc, Scope* sc) | ||
| { | ||
| for (int i = 0; i < (*elements).length; i++) | ||
| { | ||
| auto elem = (*elements)[i]; | ||
| if (elem) | ||
| (*elements)[i] = elem.resolveLoc(loc, sc); | ||
| } | ||
| return this; | ||
| } | ||
|
|
||
| override void accept(Visitor v) | ||
| { | ||
| v.visit(this); | ||
|
|
@@ -4282,7 +4293,7 @@ extern (C++) abstract class UnaExp : Expression | |
|
|
||
| } | ||
|
|
||
| override final Expression resolveLoc(const ref Loc loc, Scope* sc) | ||
| override Expression resolveLoc(const ref Loc loc, Scope* sc) | ||
| { | ||
| e1 = e1.resolveLoc(loc, sc); | ||
| return this; | ||
|
|
@@ -5164,6 +5175,16 @@ extern (C++) final class CallExp : UnaExp | |
| return this; | ||
| } | ||
|
|
||
| override Expression resolveLoc(ref const Loc loc, Scope* sc) | ||
| { | ||
| for (int i = 0; i < arguments.length; i++) | ||
| { | ||
| auto arg = (*arguments)[i]; | ||
| if (arg) | ||
| (*arguments)[i] = arg.resolveLoc(loc, sc); | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| return this; | ||
| } | ||
| override void accept(Visitor v) | ||
| { | ||
| v.visit(this); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,7 +11,7 @@ struct Line | |
|
|
||
| void foo(Line line1 = __LINE__, int line2 = __LINE__, int line3 = int(__LINE__)) | ||
| { | ||
| assert(line1 == 12); | ||
| assert(line1 == 21); | ||
| assert(line2 == 21); | ||
| assert(line3 == 12); | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can also be modified to print 21, however, according to @WalterBright in this comment this sort of construction is used to retain the C++ behavior of LINE
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also have bugs about |
||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| // https://issues.dlang.org/show_bug.cgi?id=23403 | ||
| struct Context | ||
| { | ||
| string pretty_function; | ||
| } | ||
|
|
||
| void test23403(Context ctx = Context(__FUNCTION__)) | ||
| { | ||
| assert(ctx.pretty_function == "testFUNCTION.main"); | ||
| } | ||
|
|
||
| // https://issues.dlang.org/show_bug.cgi?id=23408 | ||
| string foo(string arg) | ||
| { | ||
| return arg; | ||
| } | ||
|
|
||
| void test23408(string s = foo(__FUNCTION__)) | ||
| { | ||
| assert(s == "testFUNCTION.main"); | ||
| } | ||
|
|
||
| void main() | ||
| { | ||
| test23403(); | ||
| test23408(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
foreach (ref elem; (*elements)[])
if (elem)
elem = elem.resolveLoc(loc, sc);