Skip to content

Commit

Permalink
Fix: delay disable_item 'id' validations to allow use of user-defined…
Browse files Browse the repository at this point in the history
… constants
  • Loading branch information
glx22 committed Jul 10, 2024
1 parent e6b7ef4 commit a8ae18c
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions nml/ast/disable_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,17 @@ def __init__(self, param_list, pos):
"disable_item() requires between 1 and 3 parameters, encountered {:d}.".format(len(param_list)), pos
)
self.feature = general.parse_feature(param_list[0])
self.first_id = param_list[1] if len(param_list) > 1 else None
self.last_id = param_list[2] if len(param_list) > 2 else None

if len(param_list) > 1:
self.first_id = param_list[1].reduce_constant(global_constants.const_list)
else:
self.first_id = None
def pre_process(self):
if self.first_id is not None:
self.first_id = self.first_id.reduce_constant(global_constants.const_list)

if len(param_list) > 2:
self.last_id = param_list[2].reduce_constant(global_constants.const_list)
if self.last_id is not None:
self.last_id = self.last_id.reduce_constant(global_constants.const_list)
if self.last_id.value < self.first_id.value:
raise generic.ScriptError("Last id to disable may not be lower than the first id.", pos)
else:
self.last_id = None
raise generic.ScriptError("Last id to disable may not be lower than the first id.", self.last_id.pos)

def debug_print(self, indentation):
generic.print_dbg(indentation, "Disable items, feature=" + str(self.feature.value))
Expand Down

0 comments on commit a8ae18c

Please sign in to comment.