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

dtoh: Properly handle default values of function arguments #11866

Merged
merged 1 commit into from
Oct 14, 2020

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Oct 13, 2020

Removes the special casing in favour of visiting the actual expression and implements handlers for expressions which require different syntax in C++ (e.g. static member access, implicit dereferencing of pointers, ...).

CC @Geod24

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + dmd#11866"

m = 1LL,
};

extern void enums(uint64_t e = $?:32=1LLU|64=E::m$);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

THis is necessary because the frontend generates different AST's for -m32 (IntegerExp) and -m64 (DotIdExp) ...

@@ -1703,7 +1703,7 @@ struct ParameterList
Array<Parameter*>* parameters;
StorageClass stc;
VarArg varargs;
ParameterList(Array<Parameter*>* parameters, VarArg varargs = cast(VarArg)cast(ubyte)0u, StorageClass stc = 0);
ParameterList(Array<Parameter*>* parameters, VarArg varargs = (VarArg)0u, StorageClass stc = 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this still a cast, but STC is displayed correctly ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

StorageClass is a typedef, not an enum.

@@ -750,7 +750,7 @@ struct Loc
const char* filename;
uint32_t linnum;
uint32_t charnum;
const char* toChars(bool showColumns, uint8_t messageStyle) const;
const char* toChars(bool showColumns = global.params.showColumns, uint8_t messageStyle = global.params.messageStyle) const;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will trigger a forward reference error, since global (the variable) is declared at L7118

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, the added code will now properly emit forward references (but there are some more issues in the existing code which i would rather defer into another PR)

@Geod24
Copy link
Member

Geod24 commented Oct 14, 2020

That would also fix https://issues.dlang.org/show_bug.cgi?id=21304 right ?

@MoonlightSentinel
Copy link
Contributor Author

That would also fix https://issues.dlang.org/show_bug.cgi?id=21304 right ?

Yes

Removes the special casing in favour of visiting the actual expression
and implements handlers for expressions which require different syntax
in C++ (e.g. static member access, implicit dereferencing of pointers,
...).
Copy link
Member

@Geod24 Geod24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noice

@Geod24 Geod24 merged commit 2cf3ca3 into dlang:master Oct 14, 2020
@MoonlightSentinel MoonlightSentinel deleted the dtoh-default-args branch October 17, 2020 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants