Skip to content

Commit

Permalink
[gc_heap] Fix silly dict_set() template dispatch bug!
Browse files Browse the repository at this point in the history
Gah this took way too long to debug!

Unrelated:

[doc] Clarify eggex doc
  • Loading branch information
Andy Chu committed Dec 24, 2020
1 parent 4ef8288 commit 6f847d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 26 deletions.
13 changes: 9 additions & 4 deletions doc/eggex.md
Expand Up @@ -287,14 +287,19 @@ performance problems.

### Flags and Translation Preferences (`;`)

Flags or "regex modifiers" appear after the first semicolon:
Flags or "regex modifiers" appear after a semicolon:

/ digit+ ; ignorecase /

A translation preference looks like `%pref`. It controls what regex syntax the
eggex is translated to by default.
A translation preference is specified with a symbol like `%pref`. It controls
what regex syntax the eggex is translated to by default.

/ digit+ ; ignorecase %ERE /
/ digit+ ; %ERE / # translates to [[:digit:]]+
/ digit+ ; %python / # translates to \d+

Flags and translation preferences together:

/ digit+ ; ignorecase %python / # translates to (?i)\d+

### Multiline Syntax

Expand Down
2 changes: 1 addition & 1 deletion mycpp/gc_heap.h
Expand Up @@ -1296,7 +1296,7 @@ void dict_set(Dict<K, V>* self, K key, V val) {

// e.g. Dict<Str*, int>
template <typename K, typename V>
void dict_set(Dict<K, V*>* self, K* key, V val) {
void dict_set(Dict<K*, V>* self, K* key, V val) {
StackRoots _roots({&self, &key});

self->reserve(self->len_ + 1);
Expand Down
21 changes: 0 additions & 21 deletions mycpp/gc_heap_test.cc
Expand Up @@ -401,27 +401,6 @@ TEST dict_test() {

TEST dict_repro() {
// For isolation
Str* foo = nullptr;
StackRoots _roots1({&foo});
// auto dict_si = NewDict<Str*, int>();
Dict<Str*, int>* dict_si = nullptr;
StackRoots _roots2({&dict_si});
dict_si = NewDict<Str*, int>();
log("dict_si = %p", dict_si);
gHeap.from_space_.AssertValid(dict_si);

Dict<int, Str*>* dict_is = nullptr;
log("dict_is = %p", dict_is);

StackRoots _roots3({&dict_is});
dict_is = NewDict<int, Str*>();
log("dict_is = %p", dict_is);
gHeap.from_space_.AssertValid(dict_is);

foo = NewStr("foo");

dict_si->set(foo, 42); // creates slab that's not valid?
dict_is->set(42, kEmptyString); // crash

PASS();
}
Expand Down

0 comments on commit 6f847d7

Please sign in to comment.