Bug 3163 – Never referenced local variable compiles without error.

Status
RESOLVED
Resolution
DUPLICATE
Severity
minor
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
All
OS
All
Creation time
2009-07-10T16:11:00Z
Last change time
2014-04-18T09:12:07Z
Keywords
accepts-invalid
Assigned to
nobody
Creator
peng2cheng2

Comments

Comment #0 by peng2cheng2 — 2009-07-10T16:11:15Z
Per Paragraph 2, "Local Variables" in "Functions" DMD 2.0, it is an error to declare a local variable that is never referred to. But this compiles and runs fine: --- code import std.stdio; void main(){ int i = 10; //never referred to -- should be error ? int k; writefln("%d", i + 3); } --- terminal ex$> /opt/dmd2/linux/bin/dmd2 Digital Mars D Compiler v2.029 Copyright (c) 1999-2009 by Digital Mars written by Walter Bright Documentation: http://www.digitalmars.com/d/2.0/index.html ex$> /opt/dmd2/linux/bin/dmd2 func.d ex$> ./func 13
Comment #1 by smjg — 2009-07-14T16:37:48Z
Uh, your comment is on the wrong line.
Comment #2 by yebblies — 2011-06-10T11:14:55Z
*** This issue has been marked as a duplicate of issue 3960 ***