Greetings everybody,
I think that I have found a bug in gpc. The following program generates what I think is a spurious error...of course I could be mistaken.
-------------------
program testzero1(input,output); type seabird= record alive:boolean; tomin:real; end ; var tu:real; i,ndives:integer; cguille:seabird;
procedure zero(function target(x:real):real;lox,hix:real;var x:real; var found:boolean); begin end { zero };
function fed(var cbird:seabird;var tu:real):seabird; var found:boolean;
function oo1(var t:real):real; begin oo1:=0; end { oo1 }; begin with cbird do zero(oo1,0,10000,tomin,found); fed:=cbird; end ; begin cguille:=fed(cguille,tu); end . ---- The error is:
testzero1.p: In function `Fed': testzero1.p:26: type mismatch in argument 1 of `Zero'
I don't think that there is an error, especially not the one indicated, but I usually believe the compiler's parser rather than my own.
What do you think?
Thanks, in advance,
John Ollason
j.g.ollason wrote:
I think that I have found a bug in gpc. The following program generates what I think is a spurious error...of course I could be mistaken.
program testzero1(input,output); type seabird= record alive:boolean; tomin:real; end ; var tu:real; i,ndives:integer; cguille:seabird;
procedure zero(function target(x:real):real;lox,hix:real;var x:real; var found:boolean); begin end { zero };
function fed(var cbird:seabird;var tu:real):seabird; var found:boolean;
function oo1(var t:real):real; begin oo1:=0; end { oo1 }; begin with cbird do zero(oo1,0,10000,tomin,found); fed:=cbird; end ; begin cguille:=fed(cguille,tu); end .
The error is:
testzero1.p: In function `Fed': testzero1.p:26: type mismatch in argument 1 of `Zero'
The error is correct. In target, x is a value parameter, but in oo1, it's a reference parameter. Therefore the types don't match.
Frank
I did try to withdraw this posting when I found the bug.
See my previous posting on the subject.
Abject self-imposed humiliation of a Pascal user who bought the silver book in 1979. I suppose it's the onset of senility...
I apologise.
Can't say any ore than that.
John Ollason
----
On Fri, 26 Apr 2002, Frank Heckenbach wrote:
j.g.ollason wrote:
I think that I have found a bug in gpc. The following program generates what I think is a spurious error...of course I could be mistaken.
program testzero1(input,output); type seabird= record alive:boolean; tomin:real; end ; var tu:real; i,ndives:integer; cguille:seabird;
procedure zero(function target(x:real):real;lox,hix:real;var x:real; var found:boolean); begin end { zero };
function fed(var cbird:seabird;var tu:real):seabird; var found:boolean;
function oo1(var t:real):real; begin oo1:=0; end { oo1 }; begin with cbird do zero(oo1,0,10000,tomin,found); fed:=cbird; end ; begin cguille:=fed(cguille,tu); end .
The error is:
testzero1.p: In function `Fed': testzero1.p:26: type mismatch in argument 1 of `Zero'
The error is correct. In target, x is a value parameter, but in oo1, it's a reference parameter. Therefore the types don't match.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html
I was completely wrong. I was dreaming. It was an elementary blunder when I was pre-occupied with something else. I missed the _var_ in the parameter list. Mea culpa...
John Ollason
------
On Tue, 23 Apr 2002, j.g.ollason wrote:
Greetings everybody,
I think that I have found a bug in gpc. The following program generates what I think is a spurious error...of course I could be mistaken.
program testzero1(input,output); type seabird= record alive:boolean; tomin:real; end ; var tu:real; i,ndives:integer; cguille:seabird;
procedure zero(function target(x:real):real;lox,hix:real;var x:real; var found:boolean); begin end { zero };
function fed(var cbird:seabird;var tu:real):seabird; var found:boolean;
function oo1(var t:real):real; begin oo1:=0; end { oo1 }; begin with cbird do zero(oo1,0,10000,tomin,found); fed:=cbird; end ; begin cguille:=fed(cguille,tu); end .
The error is:
testzero1.p: In function `Fed': testzero1.p:26: type mismatch in argument 1 of `Zero'
I don't think that there is an error, especially not the one indicated, but I usually believe the compiler's parser rather than my own.
What do you think?
Thanks, in advance,
John Ollason