[Issue 13228] New: Value range analysis for the length of slices
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Wed Jul 30 11:46:37 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13228
Issue ID: 13228
Summary: Value range analysis for the length of slices
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: enhancement
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: bearophile_hugs at eml.cc
I suggest to introduce in D a value range analysis and propagation for the
length of slices, it should allow code like (currently refused):
void foo(int[100]) {}
ubyte x = 100;
void main() {
const int[] a = new int[x];
foo(a);
}
That currently gives:
test.d(5,8): Error: function test.foo (int[100] _param_0) is not callable using
argument types (const(int[]))
That is comparable to code like this (that is accepted by dmd 2.066beta5):
void foo(ubyte) {}
ubyte x = 100;
void main() {
const int a = x;
foo(a);
}
--
More information about the Digitalmars-d-bugs
mailing list