Skip to content

Commit

Permalink
fixfix
Browse files Browse the repository at this point in the history
  • Loading branch information
AngheloAlf committed Nov 23, 2023
1 parent 6eb13ec commit 3b8634a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions util/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,13 @@ def parse_optional_opt(self, opt: str, t: Type[T]) -> Optional[T]:
def parse_optional_opt_with_default(self, opt: str, t: Type[T], default: Optional[T]) -> Optional[T]:
if opt not in self._yaml:
return default
return self.parse_opt(opt, t)
self._read_opts.add(opt)
value = self._yaml[opt]
if value is None or isinstance(value, t):
return value
if t is float and isinstance(value, int):
return cast(T, float(value))
raise ValueError(f"Expected {opt} to have type {t}, got {type(value)}")

def parse_opt_within(
self, opt: str, t: Type[T], within: List[T], default: Optional[T] = None
Expand Down Expand Up @@ -432,7 +438,7 @@ def parse_endianness() -> Literal["big", "little"]:
"segment_symbols_style", str, ["splat", "makerom"], "splat"
),
ld_rom_start=p.parse_opt("ld_rom_start", int, 0),
ld_fill_value=p.parse_optional_opt_with_default("ld_fill_value", Optional[int], 0),
ld_fill_value=p.parse_optional_opt_with_default("ld_fill_value", int, 0),
ld_bss_is_noload=p.parse_opt("ld_bss_is_noload", bool, True),
create_c_files=p.parse_opt("create_c_files", bool, True),
auto_decompile_empty_functions=p.parse_opt(
Expand Down

0 comments on commit 3b8634a

Please sign in to comment.