Skip to content

Commit

Permalink
Fix: Register named parameters earlier
Browse files Browse the repository at this point in the history
  • Loading branch information
glx22 committed Aug 4, 2023
1 parent bbe945e commit fe79d80
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions nml/actions/actionD.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,8 @@ def __init__(self, param, value):
self.param = param
self.value = value

def pre_process(self):
self.value = self.value.reduce(global_constants.const_list)

self.param = self.param.reduce(global_constants.const_list, unknown_id_fatal=False)
if isinstance(self.param, expression.SpecialParameter):
if not self.param.can_assign():
raise generic.ScriptError(
"Trying to assign a value to the read-only variable '{}'".format(self.param.name), self.param.pos
)
elif isinstance(self.param, expression.Identifier):
def register_names(self):
if isinstance(self.param, expression.Identifier):
if global_constants.identifier_refcount[self.param.value] == 0:
generic.print_warning(
generic.Warning.OPTIMISATION,
Expand All @@ -110,6 +102,16 @@ def pre_process(self):
return
num = action6.free_parameters.pop_unique(self.pos)
global_constants.named_parameters[self.param.value] = num

def pre_process(self):
self.value = self.value.reduce(global_constants.const_list)

self.param = self.param.reduce(global_constants.const_list, unknown_id_fatal=False)
if isinstance(self.param, expression.SpecialParameter):
if not self.param.can_assign():
raise generic.ScriptError(
"Trying to assign a value to the read-only variable '{}'".format(self.param.name), self.param.pos
)
elif not isinstance(self.param, expression.Parameter):
raise generic.ScriptError("Left side of an assignment must be a parameter.", self.param.pos)

Expand Down

0 comments on commit fe79d80

Please sign in to comment.