Bug report: Object interface/implementation conflict
Hello Folks! Got the following bug today: type ... tPruzzel = object Procedure amazooka ( proe: pProe ); end (* tPruzzel *); ... tPruzzel.amazooka ( p: pProe ); begin (* tPruzzel.amazooka *) --> if p = nil then ... end (* tPruzzel.amazooka *); The "-->" marked line yields a compiler error: "undefined identifier 'p'". To avoid it, the variable _identifier_ in interface and implementation must be the same. I don't know, if this case intentionally yields an error; anyway, I think it should be a "header does not match", not an "undefined identifier". The latter one's confusing. Yours Markus
On 21 Mar 01, at 20:40, Markus Gerwinski wrote:
Hello Folks!
Got the following bug today:
type ... tPruzzel = object Procedure amazooka ( proe: pProe ); end (* tPruzzel *);
...
tPruzzel.amazooka ( p: pProe );
begin (* tPruzzel.amazooka *) --> if p = nil then ... end (* tPruzzel.amazooka *);
The "-->" marked line yields a compiler error: "undefined identifier 'p'".
It is not a bug. "p" *is* undefined.
To avoid it, the variable _identifier_ in interface and implementation must be the same.
Of course.
I don't know, if this case intentionally yields an error; anyway, I think it should be a "header does not match", not an "undefined identifier".
There are two errors. The header does not match and "p" is undefined. I am not sure however that it makes a difference which of the two errors is reported by the compiler. Best regards, The Chief -------- Prof. Abimbola A. Olowofoyeku (The African Chief) Author of: Chief's Installer Pro for Win32 http://www.bigfoot.com/~African_Chief/chief32.htm Email: African_Chief@bigfoot.com
Markus Gerwinski wrote:
Hello Folks!
Got the following bug today:
type ... tPruzzel = object Procedure amazooka ( proe: pProe ); end (* tPruzzel *);
...
tPruzzel.amazooka ( p: pProe );
begin (* tPruzzel.amazooka *) --> if p = nil then ... end (* tPruzzel.amazooka *);
The "-->" marked line yields a compiler error: "undefined identifier 'p'". To avoid it, the variable _identifier_ in interface and implementation must be the same.
I don't know, if this case intentionally yields an error; anyway, I think it should be a "header does not match", not an "undefined identifier". The latter one's confusing.
That's a known bug, AFAIK. When "repeating" a forward etc. declaration, GPC ignores the parameter names and takes the names from the first declaration (here: proe). This has confused me more than once, too. Frank -- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/ GPC To-Do list, latest features, fixed bugs: http://agnes.dida.physik.uni-essen.de/~gnu-pascal/todo.html
Hello Folks! Prof Abimbola Olowofoyeku wrote:
tPruzzel.amazooka ( p: pProe );
begin (* tPruzzel.amazooka *) --> if p = nil then ... end (* tPruzzel.amazooka *);
The "-->" marked line yields a compiler error: "undefined identifier 'p'". It is not a bug. "p" *is* undefined.
It is _not_. It is defined in the header of the method implementation. _If_ there is an error, it's the difference between interface and implementation. (As Frank wrote, it is a known bug, but I just wanted to clarify this.) Yours Markus
participants (3)
-
Frank Heckenbach -
Markus Gerwinski -
Prof Abimbola Olowofoyeku