Skip to content

Conversation

Biotronic
Copy link
Contributor

As discussed in https://issues.dlang.org/show_bug.cgi?id=14561, this pull makes EnumMembers use divide-and-conquer (through staticMap), and adds to NoDuplicates support for lists longer than 500 elements.

@yebblies
Copy link
Contributor

Fails on autotester, and indentation needs fixing.

@McSherry
Copy link
Contributor

PR title should probably be expanded: http://wiki.dlang.org/Pull_Requests#Create_a_pull_request

Choose a title for your pull request that clearly states what it does. When fixing a bug, the usual thing to do is to use the summary from the bugzilla report. Eg a title like "Fix 3797" or "Issue 3797" contains much less information than "Fix Issue 3797 - Regression(2.038): Implicit conversion between incompatible function pointers" and requires a lot more effort for the reviewers to determine if it is something they are interested in.

@schveiguy schveiguy changed the title Fix for 14561 Fix 14561 - Large enums cannot be parsed due to too many recursive template expansions May 12, 2015
@schveiguy
Copy link
Member

PR title should probably be expanded

Yes, thanks for noticing. That's a pet peeve of mine.

@quickfur
Copy link
Member

ping
There are merge conflicts, please rebase.

@Hackerpilot
Copy link
Contributor

@Biotronic can you update this pull so that it applies cleanly?

@quickfur
Copy link
Member

ping @Biotronic
Rebase please?

@Biotronic
Copy link
Contributor Author

I'm back, baby! Sorry about the wait, I've had the last few months of my life ruined by near-constant migraines, but have finally found medication that works.

@quickfur
Copy link
Member

Good to hear! Could you also squash the commits?

@Biotronic
Copy link
Contributor Author

Is that good enough, or should I go all the way back to f9e0862?

@quickfur
Copy link
Member

What is 0e3b7ff for? It looks a bit fishy to me. Technically we're supposed to be working on topic branches so that we can merge back to master here as a single branch. But no matter, I don't think it's a big deal.

LGTM.

@Biotronic
Copy link
Contributor Author

It's when I pulled from https://github.com/D-Programming-Language/phobos/. Maybe I'm doing it wrong?

@dnadlinger
Copy link
Contributor

The idea would be to rebase your work on top of the new master branch, this way avoiding to create a merge commit.

@@ -3467,6 +3474,45 @@ unittest
static assert(__traits(identifier, EnumMembers!E[2]) == "b");
}

unittest { // Huge enums
enum TLAs { aa, ab, ac, ad, ae, af, ag, ah, ai, aj, ak, al, am, an, ao, ap, aq, ar, as, at,
Copy link

Choose a reason for hiding this comment

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

Wouldn't it be acceptable to use template meta programming to generate this ?!

string genEnum()
{
    string result = "enum TLAs {";
    foreach(c0; 'a'..'z')
        foreach(c1; 'a'..'z')
    {
        result ~= '_';
        result ~= c0;
        result ~= c1;
        result ~= ',';
    }
    result ~= '}';
    return result;
}
mixin(genEnum);

Same comment for alias LongList, upper.

@Biotronic Biotronic force-pushed the master branch 2 times, most recently from 38309b6 to b68cf53 Compare April 1, 2016 20:31
@Biotronic
Copy link
Contributor Author

Cleaned up commits and unit test code. I seem to be getting the hang of this Git thing now. (Please correct me if I'm wrong :p)

@@ -3459,6 +3466,31 @@ unittest // duplicated values
static assert([ EnumMembers!A ] == [ A.a, A.b, A.c, A.d, A.e ]);
}

unittest // huge enums
Copy link

Choose a reason for hiding this comment

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

Could you comment with \\ bugzilla 14561 instead ? It seems that this is widely done for unittest realted to bug fixes. If someone read the code, with \\ huge enums, it's not clear that it used to be a bug.

Copy link
Member

Choose a reason for hiding this comment

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

@bbasile you mean // bugzilla 14561, right?

Copy link

Choose a reason for hiding this comment

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

Yes.

@DmitryOlshansky
Copy link
Member

LGTM

@ghost
Copy link

ghost commented Apr 9, 2016

Yes plz, this is a bug fix.

@DmitryOlshansky
Copy link
Member

Auto-merge toggled on

@DmitryOlshansky DmitryOlshansky merged commit fda2df5 into dlang:master Apr 9, 2016
@Laeeth
Copy link
Contributor

Laeeth commented Jul 8, 2016

Did this PR just raise the limit? It sounds like it was intended to work with any size enums, but on a large enum of about 20,000 I get recursive template expansion errors still.

@ghost
Copy link

ghost commented Jul 8, 2016

A phobos version that includes the fix is not yet released, the latest release was a dot release so it just included the regressions.

(pulled the 9 of april in master and 2.071 was released the 5.)

So it's ok if it doesn't work, unless you use a nightly or a version build from the master branch, in which case this would be a problem.

@JackStouffer
Copy link
Contributor

@Laeeth if you need this commit, please check out the nightly releases: https://dlang.org/download.html#dmd-nightly

@Biotronic
Copy link
Contributor Author

@Laeeth: Yes, it only raises the limit. It changes the implementation to a divide-and-conquer pattern, so the limit is 2^500 instead of 500. You're likely to run into other problems at that point.

@Laeeth
Copy link
Contributor

Laeeth commented Jul 31, 2016

Thanks, for the colour everyone. I switched to using a file loaded at launch instead.

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.