Waldek Hebisch wrote:
Frank Heckenbach wrote:
Waldek Hebisch wrote:
After the patch is applied `fjf490.pas' fails. However, I think that `fjf490.pas' is wrong. At least in standard mode accessing buffer variable when at the end of file is _not_ an error: the postcondition of `get' says that at the end of file value of the file buffer is undefined, and I see no restriction on access to undefined variables.
What about this (6.8.1: Expressions - General):
: When a primary is used, it shall be an error if the variable : denoted by a variable?access of the primary is undefined. : : primary > variable?access
Yes, we may raise error in `fjf490.pas'.
Of course, we could say that we currently don't check for undefined access in general (as a processor is permitted to leave errors undetected), so why should we bother here?
Worse, ATM we fail correct programs (the original report was about a program _writing_ to the buffer variable). AFAICS to properly distinguish read form writes we have to do that in the core compiler. It seems that we could do that using apropriate tree code and delaying expansion of the reference.
Either that (though it may be impossible to check at compile-time when used as a `var' parameter), or do it at runtime by marking the buffer undefined and give an error on reading. For general undefined-checks (with normal variables) we'd probably have to do this anyway (which seems to be a huge effort, both in the compiler and at runtime, nothing I plan to do anytime soon).
The question is how much do we care.
Probably not too much. So I'm applying your change and changing fjf490.pas, but adding a comment there (for possibly future changes in this area).
Frank