Bug 3390 – [tdpl] out(result) contract should not be able to rebind result

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Linux
Creation time
2009-10-12T15:45:00Z
Last change time
2015-06-09T05:15:00Z
Keywords
patch
Assigned to
nobody
Creator
andrei

Comments

Comment #0 by andrei — 2009-10-12T15:45:51Z
This code compiles and runs: int fun() out(result) { result = 2; } body { return 1; } However, fun still returns 1 (presumably because "result" is a copy of what body returned). The compiler should disallow flat out rebinding of result.
Comment #1 by clugdbug — 2009-10-19T04:13:13Z
PATCH: Why not just make 'result' const? // func.c, line 1030. v = new VarDeclaration(loc, type->nextOf(), outId, NULL); v->noauto = 1; #if DMDV2 + v->storage_class |= STCconst; if (f->isref) { v->storage_class |= STCref | STCforeach; } #endif
Comment #2 by bugzilla — 2009-11-21T03:48:16Z
Will only fix for D2, since D1 hasn't a good notion of const.
Comment #3 by leandro.lucarella — 2009-11-22T14:39:13Z
Comment #4 by bugzilla — 2009-12-06T00:53:00Z
Fixed dmd 2.037