dmd icon indicating copy to clipboard operation
dmd copied to clipboard

Improve static array initializer checks

Open ntrel opened this issue 1 year ago • 4 comments

~Disallow~ Deprecate null literal runtime SA initializer (except as an element initializer when element type accepts null). Rationale in bug below. Disallow init as runtime SA initializer when static array length > 0. Allow init as initializer for global static array regardless of length.

Fix Issue 23381 - init as initializer of 0-sized static array

ntrel avatar Oct 03 '22 11:10 ntrel

This requires a changelog entry.

RazvanN7 avatar Oct 06 '22 06:10 RazvanN7

@ntrel Could you please add a changelog entry?

RazvanN7 avatar Nov 01 '22 08:11 RazvanN7

Allow init as initializer for global static array regardless of length.

Why? I don't understand why this should be legal:

int[1] a3 = (int[]).init; // ok

(int[]).init is null. If int[1] a3 = null is disabled why allow this?

RazvanN7 avatar Dec 19 '22 14:12 RazvanN7

ping @ntrel

RazvanN7 avatar Jul 19 '23 14:07 RazvanN7