Skip to content

Errors Thrown on Certain In-Place Operations #125

@pashneal

Description

@pashneal
def turn():
    i = 1

    #commented lines produce an error
    #uncommented lines work just fine
    i += 1
    i -= 1000
    i *= 500
    i /= 500
    i = i // 500
    #i //= 500

    i = 50
    i = i << 1
    #i <<= 1
    i = i >> 1
    #i >>= 1
    i = i % 1
    #i %= 1

    i = {0,1,2,3,4,5}
    #i ^= { 1 }
    i = i ^ {1}
    #i |= {0}
    i = i | {0}
    # i &= i
    i = i & i

It seems that only the most common operations have their equivalent in place operation allowed.
The following error is produced:

File "/home/user/.local/lib/python3.6/site-packages/battlehack20/engine/container/runner.py", line 218, in do_turn
    exec(self.locals['turn'].__code__, self.globals, self.locals)
  File "bot.py", line 26, in turn
    i &= i
  File "/home/user/.local/lib/python3.6/site-packages/battlehack20/engine/container/runner.py", line 122, in inplacevar_call
    raise SyntaxError('Unsupported in place op "' + op + '".')
  File "<string>", line None
SyntaxError: Unsupported in place op "&=".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions