0

I have following test case:

test_different_cursor: BOOLEAN
        local
            cursor: SET_ITERATION_CURSOR[INTEGER, INTEGER]
            sets: ARRAY[SET[INTEGER, INTEGER]]
        do
            create sets.make_empty

            check  attached {SET_ITERATION_CURSOR[INTEGER, INTEGER]} d.different_cursor as current_cursor then
                cursor := current_cursor
            end
            from
            until
                cursor.after
            loop
                sets.force (cursor.item, sets.count + 1)
                cursor.forth
            end

        end

Here, in loop of from~end, I try to call Array class's force feature, but the compiler keep saying following error for that line:

    Error code: VUAR(2)

Type error: non-compatible actual argument in feature call. 
What to do: make sure that type of actual argument is compatible with
  the type of corresponding formal argument. 

Class: MY_TESTS
Feature: test_different_cursor
Called feature: force (v: [like item] G; i: INTEGER_32) from ARRAY
Argument name: v
Argument position: 1
Formal argument type: SET [INTEGER_32, INTEGER_32]
Actual argument type: TUPLE [INTEGER_32, INTEGER_32]
Line: 193
        loop
->        sets.force (cursor.item, sets.count + 1)
          cursor.forth

In this case, it seems like I need to make SET class which inherits ARRAY class and redefine force feature there. But I am not really sure it's the correct way to fix compile error. Here is what my SET class look like:

class
    SET[A, B]

create
    make

feature
    valueA: A
    valueB: B

feature
    make (first: A; second: B)
        do
            valueA := first
            valueB := second
        end
end

What I have to do in order to fix this?

Miku
  • 41
  • 1
  • 5
  • It would help if you provide more detailed information reported in `VUAR(2)`, such as the type of the actual argument. From the current code it's difficult to infer what `cursor.item` returns. Alternatively you can provide the short form of the class `SET_ITERATION_CURSOR`. – Alexander Kogtenkov Oct 23 '17 at 16:35
  • @AlexanderKogtenkov Error code: VUAR(2) Type error: non-compatible actual argument in feature call. What to do: make sure that type of actual argument is compatible with the type of corresponding formal argument. Class: MY_TESTS Feature: test_different_cursor – Miku Oct 23 '17 at 16:41
  • What about the types? – Alexander Kogtenkov Oct 23 '17 at 17:49
  • @AlexanderKogtenkov Sorry, didn't notice there were more, thus I just added those more errors above. – Miku Oct 23 '17 at 19:42

1 Answers1

0

The value returned by cursor.item needs to be converted to SET [INTEGER, INTEGER]. This can be done by adding a local variable

t: TUPLE [first: INTEGER; second: INTEGER]

to the feature test_different_cursor and changing the line

sets.force (cursor.item, sets.count + 1)

into

t := cursor.item
sets.force (create {SET [INTEGER, INTEGER]}.make (t.first, t.second), sets.count + 1)
Alexander Kogtenkov
  • 5,770
  • 1
  • 27
  • 35