Thread overview
[Issue 1171] New: Cannot create a static array with the length of a const static array in function scope
Apr 20, 2007
d-bugmail
Apr 23, 2007
d-bugmail
[Issue 1171] Cannot create a static array with the length of a const static array in function scope, D1 only
Feb 01, 2010
Don
April 20, 2007
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.


-- 

April 23, 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1171


thomas-dloop@kuehne.cn changed:

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




------- Comment #1 from thomas-dloop@kuehne.cn  2007-04-23 12:54 -------
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


-- 

February 01, 2010
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


--- Comment #2 from Don <clugdbug@yahoo.com.au> 2010-02-01 00:01:54 PST ---
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: -------