CBFalconer wrote:
Frank Heckenbach wrote:
Emil Jerabek wrote:
The problem with functional parameters seems to be more general, there is nothing special with restricted types. For example, the following program is also incorrect, and accepted by GPC:
program prog; type a=0..5; var c:a; procedure foo(function bar:integer); begin end; function baz:a; begin baz := c end; begin foo(baz) end .
Here the problem was simply that results of functional parameters weren't checked strictly enough, which is easy to fix. (Attached -- unfortunately, not all fixes are so self-explaining. ;-)
How is it incorrect? a being a subrange of integer, baz seems to satisfy the requirements for a parameter of foo. At least as I see it.
From ISO 7185, 6.6.3.5 Functional parameters:
"The result-type closest-contained by the formal-parameter-section shall denote the same type as the result type of the function."
An integer subrange type is not the same type as the integer type; therefore, baz fails the same type result type requirement.
In order for the example to legal, the requirement would have to have been compatible types for result types but that isn't what ISO 7185 (or ISO 10206) actually requires.
Gale Paeper gpaeper@empirenet.com