www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1171] New: Cannot create a static array with the length of a const static array in function scope

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1171

           Summary: Cannot create a static array with the length of a const
                    static array in function scope
           Product: D
           Version: 1.012
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: diagnostic, rejects-valid
          Severity: minor
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: deewiant gmail.com


(Set version to 1.012: there's no 1.013 yet.)

void main() {
        const int[2] foo;
        int[foo.length] bar;
}

Compiling the above results in the error "Error: no property 'length' for type
'int'". No module or line information, hence the "diagnostic" keyword on this
bug.

Move the code outside of function scope and/or remove the const from "foo" and
the code compiles.

Also, replacing foo.length with mixin("foo.length") works, which is odd.


-- 
Apr 20 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1171


thomas-dloop kuehne.cn changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         OS/Version|Windows                     |All





Added to DStress as
http://dstress.kuehne.cn/run/l/length_12_A.d
http://dstress.kuehne.cn/run/l/length_12_B.d
http://dstress.kuehne.cn/run/l/length_12_C.d


-- 
Apr 23 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1171


Don <clugdbug yahoo.com.au> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|diagnostic                  |
                 CC|                            |clugdbug yahoo.com.au
            Summary|Cannot create a static      |Cannot create a static
                   |array with the length of a  |array with the length of a
                   |const static array in       |const static array in
                   |function scope              |function scope, D1 only



The line number bug was fixed between 1.030 and 1.036.
Removing 'diagnostic' from the warning. Works on D2.
(Actually, I think the bug is that D1 allows you create a const array with no
initializer).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 01 2010