Bug 24817 – UDA on nested template does not work

Status
NEW
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2024-10-15T12:13:11Z
Last change time
2024-12-13T19:38:13Z
Assigned to
No Owner
Creator
FeepingCreature
Moved to GitHub: dmd#20536 →

Comments

Comment #0 by default_357-line — 2024-10-15T12:13:11Z
Consider this code: @(3) int foo() => 0; static assert(__traits(getAttributes, foo)[0] == 3); @(3) int bar(T)() => 0; static assert(__traits(getAttributes, bar)[0] == 3); void main() { @(3) int ffoo() => 0; static assert(__traits(getAttributes, ffoo)[0] == 3); @(3) int bbar(T)() => 0; static assert(__traits(getAttributes, bbar)[0] == 3); } Leads to: "Error: sequence index `[0]` is outside bounds `[0 .. 0]`" on the last assert only.
Comment #1 by destructionator — 2024-10-15T13:40:01Z
well i have a fix for it idk what side effects it has. but in dmd's parse.d, it is line 4880ish in my branch search for the comment "A template parameter list means it's a function template" rn *above* that line is a block `if (udas) { ... }` move that block to *below* that `if(tpl)` condition so then it attaches to the wrapped template instead of the function it is wrapping passes all tests *there*. idk about other potential regressions, but it did leave the udas accessible via the instance and the code change passes my gut test- the parser is doing a rewrite but attached udas before wrapping the template and now it attaches udas at the end fixed in opend on next push at least lol
Comment #2 by robert.schadek — 2024-12-13T19:38:13Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20536 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB