where-clauseanuraffl

FFL: second identifier from where clause not recognized


I believe my syntax is correct on this one, but for some reason the Anura FFL parser is not recognizing the second identifier choice defined in my where clause. What am I missing?

def(class creature creature, class game_state game) ->commands [
    if(creature.choices,
        if(choice < size(player.deck), [
            set(player.deck, player.deck[0:choice] + player.deck[choice+1:]),
            game.crypt.spawn_cards(creature.summoner, [card]),
            set(creature.effects_tracking['Buried Treasure'], card),
        ] where card=player.deck[choice]
        ) where player=game.players[creature.summoner],
                choice=creature.choices[0]
    ),
]

It gives me this error:

formula.cpp:1067 ASSERTION FAILED: Unknown identifier 'choice' :
if(choice < size(player.deck), [

   ^-----^

Note: if I change it to where a=... where b=... instead of where a=... , b=... then it parses.


Solution

  • The comma is being interpreted as an argument separator for if() -- it's ambiguous and impossible for the parser to tell intent. You have to use parens to disambiguate it, though I just recommend using there where...where syntax, as it's much more reliable. Commas are just too open to problems like this so this syntax on where clauses is deprecated.