Thread overview | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
January 11, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |pull --- Comment #1 from Dlang Bot <dlang-bot@dlang.rocks> --- @SixthDot updated dlang/dmd pull request #14803 "fix issue 23620 - 'alias this' is not respected in static array lengt…" fixing this issue: - fix issue 23620 - 'alias this' is not respected in static array length position does the cast to size_t before calling toInteger(), which emitted the error https://github.com/dlang/dmd/pull/14803 -- |
January 12, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 Dlang Bot <dlang-bot@dlang.rocks> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution|--- |FIXED --- Comment #2 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/dmd pull request #14803 "fix issue 23620 - 'alias this' is not respected in static array lengt…" was merged into stable: - 4ed4e2c0ff1f238a0d4cdbccc21ec3d50d8f2706 by Basile Burg: fix issue 23620 - 'alias this' is not respected in static array length position does the cast to size_t before calling toInteger(), which emitted the error https://github.com/dlang/dmd/pull/14803 -- |
January 14, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #3 from Dlang Bot <dlang-bot@dlang.rocks> --- dlang/dmd pull request #14813 "Merge Stable into master" was merged into master: - 1fe9ffb6722c902bf0a3fcd78cfb740bcbf1bc31 by Basile Burg: fix issue 23620 - 'alias this' is not respected in static array length position does the cast to size_t before calling toInteger(), which emitted the error https://github.com/dlang/dmd/pull/14813 -- |
January 14, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 Salih Dincer <salihdb@hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |salihdb@hotmail.com --- Comment #4 from Salih Dincer <salihdb@hotmail.com> --- This isn't a bug! void main() { struct Index { size_t value; alias value this; } enum size_t i = Index(); int[i] a; int[cast(size_t)Index()] b; static assert(a.length == b.length); } -- |
January 15, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #5 from Max Samukha <maxsamukha@gmail.com> --- Why? Explicit cast shouldn't be required. -- |
January 15, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #6 from Salih Dincer <salihdb@hotmail.com> --- // because : enum index1 = Index(); assert( is(typeof(index1) == struct) ); auto index2 = Index(); assert( !is(typeof(index1) == size_t) && !is(typeof(index2) == size_t) ); // but: enum index = Index(); int[index + 1] d; // automatic conversion d[0] = 42; // yeah SDB@79 -- |
January 15, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #7 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Salih Dincer from comment #6) > // because : > > enum index1 = Index(); > assert( > is(typeof(index1) == struct) > ); > > auto index2 = Index(); > assert( > !is(typeof(index1) == size_t) && > !is(typeof(index2) == size_t) > ); > > // but: > > enum index = Index(); > int[index + 1] d; // automatic conversion > d[0] = 42; // yeah > > SDB@79 I still don't understand. Static array declaration expects an integer. 'Index' implicitly converts to an integer. Why should casts or other hacks be required? -- |
January 16, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #8 from Salih Dincer <salihdb@hotmail.com> --- I don't understand too :) This code works me: struct Index(T) { T value; this(T v) { value = v; }; alias opCall this; @property opCall() inout { return value; } } enum one= Index!int(1)(); int[one] a = 1; int[Index!int(2)()] b = 2; static assert(a.length < b.length); Best regards... SDB@79 -- |
January 16, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 --- Comment #9 from Max Samukha <maxsamukha@gmail.com> --- (In reply to Salih Dincer from comment #8) > I don't understand too :) > > This code works me: > > struct Index(T) > { > T value; > > this(T v) { value = v; }; > alias opCall this; > > @property opCall() inout { > return value; > } > > } > > enum one= Index!int(1)(); > int[one] a = 1; > > int[Index!int(2)()] b = 2; > static assert(a.length < b.length); > > Best regards... > > SDB@79 You don't need to mark opCall with @property for that code to work. 'alias this' is also unnecessary. You wrote "This isn't a bug!". Did you mean this bug report is invalid? If yes, it would be nice if you explained why you think the report is invalid. -- |
January 17, 2023 [Issue 23620] 'alias this' is not respected in static array length position | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23620 Basile-z <b2.temp@gmx.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |b2.temp@gmx.com --- Comment #10 from Basile-z <b2.temp@gmx.com> --- (In reply to Salih Dincer from comment #4) > This isn't a bug! > > void main() > { > struct Index > { > size_t value; > alias value this; > } > > enum size_t i = Index(); > int[i] a; > int[cast(size_t)Index()] b; > static assert(a.length == b.length); > } before the fix DMD did a hidden cast a cast but too late. -- |
Copyright © 1999-2021 by the D Language Foundation