Skip to content

Conversation

@RazvanN7
Copy link
Contributor

No description provided.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @RazvanN7! 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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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

Auto-close Bugzilla Severity Description
18578 enhancement First enum value assigned 0 instead of EnumBaseType.init

Testing this PR locally

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

dub fetch digger
dub run digger -- build "master + dmd#8090"

@marler8997
Copy link
Contributor

Also this: #7996

}
Expression e = new IntegerExp(em.loc, 0, Type.tint32);
e = e.implicitCastTo(sc, t);
Expression e = new IntegerExp(em.loc, 0, t);
Copy link
Contributor

@marler8997 marler8997 Mar 26, 2018

Choose a reason for hiding this comment

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

Not too familiar with the AST, but @LemonBoy's change "looks" more correct:

Expression e = t.defaultInitLiteral(em.loc);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my first option also, but for some reason it led to segfaults when running the tests. From my point of view, enums are an enumeration of constants that are represented by integers behind the scenes, so this solution looks correct (notice that the cast is not needed anymore)

Copy link
Member

Choose a reason for hiding this comment

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

The trouble is there is significant code depending on it being 0. A deprecation cycle will be needed. @LemonBoy 's solution is more correct, but your test case is better. Both of you fixing the same bug is a pity, as now I have to close one. :-(

Copy link
Contributor

@marler8997 marler8997 Mar 26, 2018

Choose a reason for hiding this comment

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

Yeah merging this one first seems reasonable.

@RazvanN7 The language spec doesn't say anything about enums being "integers behind the scenes" (https://dlang.org/spec/enum.html). In fact, if enums had this restriction you couldn't do things like this:

enum message = "MyMessage"; // not an integer behind the scenes

@WalterBright
Copy link
Member

Better yet, I'll just approve this one, and regard @LemonBoy 's fix as an enhancement.

@dlang-bot dlang-bot merged commit 5cbd473 into dlang:master Mar 26, 2018
LemonBoy added a commit to LemonBoy/dmd that referenced this pull request Mar 27, 2018
Let's deprecate this behaviour that, according to the specification, is
incorrect.
Builds up on dlang#8090.
LemonBoy added a commit to LemonBoy/dmd that referenced this pull request Mar 27, 2018
Let's deprecate this behaviour that, according to the specification, is
incorrect.
Builds up on dlang#8090.
LemonBoy added a commit to LemonBoy/dmd that referenced this pull request Mar 27, 2018
Let's deprecate this behaviour that, according to the specification, is
incorrect.
Builds up on dlang#8090.
LemonBoy added a commit to LemonBoy/dmd that referenced this pull request Mar 27, 2018
Let's deprecate this behaviour that, according to the specification, is
incorrect.
Builds up on dlang#8090.
thewilsonator pushed a commit to LemonBoy/dmd that referenced this pull request Nov 22, 2018
Let's deprecate this behaviour that, according to the specification, is
incorrect.
Builds up on dlang#8090.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants