Skip to content

Commit

Permalink
Use a proper condition check when dealing with flag vectors
Browse files Browse the repository at this point in the history
When reading flag vectors, non-existent vectors are being translated
to [] (empty list). When writing them, the flag condition was
strictly checking for None and an empty list [] would result in an
empty vector being serialized, which should not happen.
Related to #871.
  • Loading branch information
delivrance committed Jan 11, 2022
1 parent db9489b commit a6299f8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compiler/api/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ def start(format: bool = False):
flag = FLAGS_RE_2.match(i[1])

if flag:
if flag.group(2) == "true":
if flag.group(2) == "true" or flag.group(2).startswith("Vector"):
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} else 0")
else:
write_flags.append(f"flags |= (1 << {flag.group(1)}) if self.{i[0]} is not None else 0")
Expand Down Expand Up @@ -441,7 +441,7 @@ def start(format: bool = False):
sub_type = arg_type.split("<")[1][:-1]

write_types += "\n "
write_types += f"if self.{arg_name} is not None:\n "
write_types += f"if self.{arg_name}:\n "
write_types += "b.write(Vector(self.{}{}))\n ".format(
arg_name, f", {sub_type.title()}" if sub_type in CORE_TYPES else ""
)
Expand Down

0 comments on commit a6299f8

Please sign in to comment.