Ver código fonte

Version 1.3.15.
Semantics of regional type guards (WITH statements) has been modified. Guarded variables of RECORD type are not read-only, but the type of the variable cannot be changed within the guarded region.

k_john_gough_cp 12 anos atrás
pai
commit
c0fa723b44
2 arquivos alterados com 20 adições e 2 exclusões
  1. 18 1
      gpcp/ExprDesc.cp
  2. 2 1
      gpcp/GPCPcopyright.cp

+ 18 - 1
gpcp/ExprDesc.cp

@@ -2867,7 +2867,24 @@ MODULE ExprDesc;
     lHash := lQual.ident.hash;
     tmp.hash := lHash;
     tmp.type := rQual.ident.type;
-    tmp.SetKind(I.conId);     (* mark immutable *)
+   (* 
+    *  It is an essential requirement of the host execution systems
+    *  that the runtime type of the guarded variable may not be changed
+    *  within the guarded region.  In the case of pointer to record
+    *  types this is guaranteed by making the "tmp" copy immutable.
+    *  Note that making the pointer variable read-only does not prevent
+    *  the guarded region from mutating fields of the record.
+    *
+    *  In case that the guarded variable is an extensible record type.
+    *  no action is required.  Any attempt to perform an entire
+    *  assignment that changes the type of the guarded variable 
+    *  will be a type-error.
+    *  For an attempted widening ...
+    *    Error 83 (Expression not assignment compatible with destination), OR
+    *  For an attempted narrowing ...
+    *    Error 143 (Cannot assign entire extensible or abstract record). 
+    *)
+    IF ~tmp.type.isRecordType() THEN tmp.SetKind(I.conId) END; (* mark immutable *)
     oldI := tmp.dfScp.symTb.lookup(lHash);
     IF oldI = NIL THEN (* not local *)
       junk := tmp.dfScp.symTb.enter(lHash, tmp);

+ 2 - 1
gpcp/GPCPcopyright.cp

@@ -45,7 +45,8 @@ MODULE GPCPcopyright;
      (* VERSION    = "1.3.10 of 15 November 2010"; *)
      (* VERSION    = "1.3.12 of 17 November 2011"; *)
      (* VERSION    = "1.3.13 of 24 July 2012"; *)
-        VERSION    = "1.3.14 of 05 September 2012"; 
+     (* VERSION    = "1.3.14 of 05 September 2012"; *)
+        VERSION    = "1.3.15 of 04 October 2012"; 
 	verStr*    = " version " + VERSION;
 
   CONST	prefix     = "#gpcp: ";