Skip to content

Mappings from tag classes that include directions always map from the rule's direction #52

@ClementSparrow

Description

@ClementSparrow

In the following code, Pos is a tag class adding top and bottom to directions and there is a mapping RotUp from Pos to Pos. However, in the first rule, even if Pos is a tag class rule parameter and the rule is non-directional, the mapping RotUp is applied on the rule direction rather than on the value of the parameter Pos as it should.

Pos = top bottom left right up down

MAPPINGS
Pos => RotUp
top bottom left right up down -> up down left right bottom top

OBJECTS
Face:Pos
white

Background
lightgreen

Wall
brown

Player
blue

COLLISIONLAYERS

Background
Face:Pos

RULES

(This rule:)
up Pos [Face:Pos] -> [Face:RotUp]

(Should be equivalent to this block, but isn't:)
  up [Face:top] -> [Face:up]
+ up [Face:bottom] -> [Face:down]
+ up [Face:left] -> [Face:left]
+ up [Face:right] -> [Face:right]
+ up [Face:up] -> [Face:bottom]
+ up [Face:down] -> [Face:top]

The expansion of the first rule is:

+ (30) UP POS=bottom [ face:bottom ] -> [ face:bottom ]
+ (30) UP POS=left [ face:left ] -> [ face:bottom ]
+ (30) UP POS=right [ face:right ] -> [ face:bottom ]
+ (30) UP POS=up [ face:up ] -> [ face:bottom ]
+ (30) UP POS=down [ face:down ] -> [ face:bottom ]

Workaround:
It's possible to avoid the issue by renaming the tags in Pos so that they have different names than those in directions. It would work fine in that example, but of course it would not work in the case where some rules would need to map on the rule's direction.

See also #43, possibly related.

Thanks to knexator for reporting the bug.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingexpansionany expansion mechanismmappingsAnything that concerns mappingssyntax/languageConcerns the language or its syntax

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions