Project

General

Profile

Bug #107

Methods of POINTER TO RECORD with CONST receiver still allowed to change receiver's fields

Added by Anton Dmitriev 10 months ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-

Description

I was told (but have not confirmed) that receiver fields should be read-only with the following declarations, but they are not:

MODULE M;
TYPE Reader = POINTER TO RECORD r: Files.Reader; eof: BOOLEAN END;
PROCEDURE (r: Reader) ReadByte (VAR b: UNSIGNED8); (* receiver is CONST by default, right? *)
VAR ch: CHAR;
BEGIN r.r.Char(ch); r.eof := r.r.res # Streams.Ok; IF ~r.eof THEN b := SYSTEM.VAL END
END ReadByte;
END M.

Compiles without errors. Should it?

Also available in: Atom PDF