alice icon indicating copy to clipboard operation
alice copied to clipboard

Functions and wildcards cannot be used in the middle of a reference anymore

Open stof opened this issue 6 years ago • 7 comments

Role:
    agency7_role:
        identifier: agency7
        assignees: '@member{131..140}'
        superiors: ['@dept2_role', '@product*_role']

Subject:
    challenge_ranking_family_custom_ranking_subject{4, 5, 7}:
        ranking: '@challenge_ranking_family_custom_ranking_dept2'
        team: '@agency<current()>_role'

None of these is working in 3.x (while they were fine in 2.x). @agency<current()>_role is parsed as the @agency<current()> reference, concatenated with _role (which of course breaks, as this reference is invalid in my fixtures, and then the concatenation would not work)

stof avatar Mar 27 '18 09:03 stof

I think we should be able to fix that one

theofidry avatar Mar 29 '18 15:03 theofidry

I would say that concatenating a reference to anything else is very unlikely to ever make sense. So we may want to change the precedence of stuff (including all the following stuff in the reference, until reaching something not making it concatenated, like the comma separating arguments of a function)

stof avatar Apr 03 '18 14:04 stof

I'd like to add that referencing dynamic property names no longer seems to be possible.

Background: I'm updating a project that is using a very old fork of Alice 1.x. It was capable of resolving references like the following:

    userGameTournamentToEarlyComplete2{1..2}:
        playerPosition: <current()>
        user: '@gameTournamentToEarlyComplete2->user<($playerPosition)>'

The user reference would resolve to either the user1 or user2. With Alice 3.4 it tries to pull the user property, which does not exist.

I've tried '@gameTournamentToEarlyComplete2->user<current()>' as well with the same results.

I can't find documentation for this usage in the manual. Dynamic reference names are documented, but not fields

Questions:

  1. Is this supposed to work and doesn't (bug) or not currently supported anymore (feature request)
  2. Should I file a separate issue for this?

kalifg avatar Aug 01 '18 22:08 kalifg

I was using the debugger, looking for a work-around, and I found out that it was parsing it as @gameTournamentToEarlyComplete2->user and <($playerPosition)>, attempting to evaluate each and then concatenate them together — this mirrors the issue author's experience more closely than my earlier evaluation.

Also I did find this work-around in case it's useful:

    userGameTournamentToEarlyComplete1{1..2}:
        playerPosition: <current()>
        user: '<(@gameTournamentToEarlyComplete1->{"getUser${playerPosition}"}())>'

Not optimal but I like it better than my co-worker's previous attempt which involved creating a custom provider to forward a request PropertyAccess like so:

    userGameTournamentToEarlyComplete{1..2}:
        playerPosition: <current()>
        user: <getProperty(@gameTournamentToEarlyComplete1, 'user', $playerPosition)>

kalifg avatar Aug 01 '18 22:08 kalifg

I think both solutions are fine, pick the one you find easier to write :)

I’m on mail so I don’t have the full thread, but yeah it’s likely this “feature” was lost. I’m using quotes because if it used to work, it was purely by luck.

I think it would be interesting to introduce back this feature but I think this would require to switch to the Hoa Compiler instead of the in house one for the Expression Language

On Thu 2 Aug 2018 at 00:48, Michael Dwyer [email protected] wrote:

I was using the debugger, looking for a work-around, and I found out that it was parsing it as @gameTournamentToEarlyComplete2->user and <($playerPosition)>, attempting to evaluate each and then concatenate them together — this mirrors the issue author's experience more closely than my earlier evaluation.

Also I did find this work-around in case it's useful:

userGameTournamentToEarlyComplete1{1..2}:
    playerPosition: <current()>
    user: '<(@gameTournamentToEarlyComplete1->{"getUser${playerPosition}"}())>'

Not optimal but I like it better than my co-worker's previous attempt which involved creating a custom provider to forward a request PropertyAccess like so:

userGameTournamentToEarlyComplete{1..2}:
    playerPosition: <current()>
    user: <getProperty(@gameTournamentToEarlyComplete1, 'user', $playerPosition)>

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/nelmio/alice/issues/912#issuecomment-409750143, or mute the thread https://github.com/notifications/unsubscribe-auth/AE76gTBaSqieQQcvhZC0wXdC2pnQM9uFks5uMjBSgaJpZM4S8mY_ .

theofidry avatar Aug 02 '18 08:08 theofidry