PR# 19412 [er] Full class checking and VUAR-2
Problem Report Summary
Submitter: axarosenberg
Category: Compiler
Priority: High
Date: 2017/11/28
Class: Bug
Severity: Serious
Number: 19412
Release: 17.11
Confidential: No
Status: Open
Responsible:
Environment: win
Synopsis: [er] Full class checking and VUAR-2
Description
When compiling the code below in full_class_checking mode, we get a VUAR-2 error:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
VUAR(2) Non-compatible actual argument in feature call.
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: Y
Source class: X
Feature: f
Called feature: put (i: INTEGER_32; a: A) from X
Argument name: a
Argument position: 2
Formal argument type: A
Actual argument type: B
Line: 12
i := Current [b]
-> Current [b] := 1
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I think that this is wrong. The code of feature `f' should first be unfolded in the context of class X, and then checked in the context of Y. So the code which should be checked in the context of Y should be:
Current.put (1, b.to_a)
And this code is valid.
Interestingly, the compiler does not complain about the previous line:
i := Current [b]
which uses a similar pattern with `b' which needs to be converted to `b.to_a' in the context of X before being checked in the context of Y.
--
Eric Bezault
To Reproduce
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class TEST
create
make
feature
make
local
y: Y
do
create y
y.f
end
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class A
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class B
convert
to_a: {A}
feature
to_a: A
do
create Result
end
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class X
feature
f
local
b: B
i: INTEGER
do
create b
i := Current [b]
Current [b] := 1
end
item alias "[]" (a: A): INTEGER assign put
do
end
put (i: INTEGER; a: A)
do
end
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class Y
inherit
X
end
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Problem Report Interactions