Skip to content
This repository has been archived by the owner on Aug 6, 2023. It is now read-only.

Commit

Permalink
Fixed error on analysing undefined arrays as args of params.
Browse files Browse the repository at this point in the history
  • Loading branch information
LordGolias committed Sep 3, 2017
1 parent 8dc92cd commit 34e94dc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion sqf/analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ def execute_code(self, code, extra_scope=None, namespace_name='missionnamespace'
return outcome

def _parse_params_args(self, arguments, base_token):
if isinstance(arguments, Anything):
if isinstance(arguments, Anything) or (isinstance(arguments, Array) and arguments.is_undefined):
return [Anything() for _ in range(len(base_token))]
return super()._parse_params_args(arguments, base_token)

Expand Down
2 changes: 1 addition & 1 deletion sqf/base_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def add_params(self, base_token, arguments=None):

if arguments is None or isinstance(arguments, Nothing):
arguments = self['_this']
if isinstance(arguments, Array):
if isinstance(arguments, Array) and not arguments.is_undefined:
arguments = arguments.value
else:
arguments = self._parse_params_args(arguments, base_token)
Expand Down
5 changes: 5 additions & 0 deletions tests/test_analyzer.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,6 +976,11 @@ def test_params_select(self):
# `_this select 0` is Anything because `_this` only has the type
self.assertEqual(Anything(), analyzer['x'])

def test_undefined_array(self):
code = '(boundingBoxReal x) params ["_x", "_y"]; _x + _y'
analyzer = analyze(parse(code))
self.assertEqual(analyzer.exceptions, [])


class SpecialContext(TestCase):
def test_insensitive__foreachindex(self):
Expand Down

0 comments on commit 34e94dc

Please sign in to comment.