On Tuesday, 7 May 2013 at 06:28:54 UTC, Timothee Cour wrote:
Then all we need is to check whether the program typechecks
under the
following type conversion rules:
global => outref //global: gc-allocated, static, etc.
output of ref-return function call => outref
outref 'dot' field => outref // field access
local => inref
global => inref
outref => inref
temporary => inref
Redundant rules should usually be avoided. For isntance, global
=> inref is pointless as global => outref => inref does it.
Example1:
ref T fooa(ref T t) { return t; }
ref T bar() { T t; return fooa(t); }
currently might compile, but has undefined behavior. Under the
new
rules (with ref meaning outref), it would not compile because
of the
illegal conversion local => outref when attempting to call
fooa(t).
Prevent valid code like T t2 = fooa(fooa(t)); in bar.