Skip to content

Commit

Permalink
vec/map: Discard literal if no output value
Browse files Browse the repository at this point in the history
  • Loading branch information
obiwac committed Oct 2, 2024
1 parent c8561df commit d5e48bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions flamingo/grammar/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ static int parse_map(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
vals[count - 1] = v;
}

if (val == NULL) {
return 0;
}

assert(*val == NULL);
*val = val_alloc();

Expand Down
4 changes: 4 additions & 0 deletions flamingo/grammar/vec.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ static int parse_vec(flamingo_t* flamingo, TSNode node, flamingo_val_t** val) {
elems[elem_count - 1] = elem;
}

if (val == NULL) {
return 0;
}

assert(*val == NULL);
*val = val_alloc();

Expand Down

0 comments on commit d5e48bd

Please sign in to comment.