increpare / PuzzleScript

Open Source HTML5 Puzzle Game Engine
MIT License
903 stars 159 forks source link

Ambiguous properties throw an exception #929

Closed ClementSparrow closed 2 years ago

ClementSparrow commented 2 years ago

This is a bug that Menderbug reported to me for Pattern:Script, but it occurs that it also happen in PuzzleScript in a slightly different form. When a property on the right-hand side of a rule is ambiguous, the rule is compiled further anyway and it causes an exception TypeError: z is undefined to be displayed in the console. Since in Pattern:Script the consequence is to throw instead an additional error message about the property not being assigned to a layer, I guess the exception is thrown in RulesToMask when accessing the layer.

Here is a minimal code to reproduce the issue:

OBJECTS

Background
black

Player
blue

A
green

B
red

LEGEND
C = A or B

SOUNDS
COLLISIONLAYERS

A 
B

RULES
right [ C | C | ] -> [ C | C | C ]

WINCONDITIONS
LEVELS
increpare commented 2 years ago

Good catch, thanks for the helpful report!