Hash table Enum objects cannot be returned from a function

RESOLVED FIXED in Firefox 55

Status

()

Core
JavaScript Engine
RESOLVED FIXED
8 months ago
8 months ago

People

(Reporter: jonco, Assigned: jonco)

Tracking

unspecified
mozilla55
Points:
---

Firefox Tracking Flags

(firefox55 fixed)

Details

Attachments

(1 attachment)

(Assignee)

Description

8 months ago
Hash table Enum objects have a deleted copy constructor and hence a deleted move constructor, so you can't do this:

using Map = js::HashMap<int, int, js::DefaultHasher<int>, js::SystemAllocPolicy>;

Map::Enum enumerateSuff()
{
    return Map::Enum(map);
}

We should give Enum a move constructor to allow this reasonable behaviour.
(Assignee)

Comment 1

8 months ago
Created attachment 8868998 [details] [diff] [review]
bug1365654-enum-move

Add a move constructor to HashTable::Enum.
Assignee: nobody → jcoppeard
Attachment #8868998 - Flags: review?(luke)

Comment 2

8 months ago
Comment on attachment 8868998 [details] [diff] [review]
bug1365654-enum-move

Review of attachment 8868998 [details] [diff] [review]:
-----------------------------------------------------------------

Makes sense

::: js/src/jsapi-tests/testHashTable.cpp
@@ +388,5 @@
>  
>  END_TEST(testHashMapLookupWithDefaultOOM)
>  #endif // defined(DEBUG)
> +
> +BEGIN_TEST(testHashTableMovableEnum)

Could you add a test that creates an Enum e1, removes an element or two, move-constructs an Enum e2, and then removes a few more elements?
Attachment #8868998 - Flags: review?(luke) → review+

Comment 3

8 months ago
Pushed by jcoppeard@mozilla.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/2996f5f166a2
Add a move constructor to HashTable::Enum r=luke

Comment 5

8 months ago
bugherder
https://hg.mozilla.org/mozilla-central/rev/2996f5f166a2
https://hg.mozilla.org/mozilla-central/rev/e6f10f6af43d
Status: NEW → RESOLVED
Last Resolved: 8 months ago
status-firefox55: --- → fixed
Resolution: --- → FIXED
Target Milestone: --- → mozilla55
You need to log in before you can comment on or make changes to this bug.