lauramcastro / readspec

ReadSpec application: making PBT easier to read for humans
MIT License
4 stars 1 forks source link

Error with [X|Y] #8

Open miguelafr opened 9 years ago

miguelafr commented 9 years ago

With a QuickCheck state machine that has an operation that defines the following next_state function:

create_room_next(S, _R, [RoomId, _Description])
    when RoomId =:= "" -> S;
create_room_next(S, _R, [RoomId, Description])->
    case search_room(RoomId, S#state.rooms) of
        {value, _Room} ->
            S;
        false ->
            NewRoom = #roomType{
                         anyAttrs = [],
                         roomId = RoomId,
                         description = get_description(Description)
                        },
            S#state {
              rooms = [NewRoom |  S#state.rooms]
            }
    end.

I get the following error:

> see:scan_and_print_model('/home/miguelafr/Projects/PROWESS/vodkatv_testing/vtv_api_admin/src/vodkatv_eqc_new_simple.erl').
** exception error: no case clause matching variable
     in function  erl_syntax:list_elements/2 (erl_syntax.erl, line 2532)
     in call from erl_syntax:list_elements/1 (erl_syntax.erl, line 2529)
     in call from nestcond:explain_ast/4 (src/symbolic-execution/nestcond.erl, line 742)
     in call from nestcond:'-explain_ast/4-lc$^2/1-0-'/4 (src/symbolic-execution/nestcond.erl, line 782)
     in call from nestcond:'-explain_ast/4-lc$^2/1-0-'/4 (src/symbolic-execution/nestcond.erl, line 786)
     in call from nestcond:explain_ast/4 (src/symbolic-execution/nestcond.erl, line 778)
     in call from nestcond:ppr_result/2 (src/symbolic-execution/nestcond.erl, line 734)
     in call from nestcond:ppr_expansion_aux/1 (src/symbolic-execution/nestcond.erl, line 595)

If I replace this code:

S#state {
    rooms = [NewRoom |  S#state.rooms]
}

with this code:

S#state {
    rooms = S#state.rooms
 }

I don't get the error, so I guess the problem is in that line. I've tried to avoid the expression [NewRoom | S#state.rooms] using a function add(NewRoom, S#state.rooms), where:

add(X, Y) -> [X | Y].

but I still get the error.

palas commented 9 years ago

A way to get around this should be to move the "add" function you created to a different module. It should not throw an exception anyway (bug). I can probably implement the cons operator later (enhancement).

miguelafr commented 9 years ago

That approach works. We can mark this ticket with a low priority if you want.