January 12, 2006 [ .. ] isn't parsed correctly in nested template char[] parameters | ||||
---|---|---|---|---|
| ||||
The error message is: found '..' when expecting ']' But it compiles correctly if parentheses are used around either of the slice arguments. It only seems to happen if the string itself comes from another char[] parameter. Tested on DMD 0.141, 0.142 and 0.143. ----------------------------------------- template whale(char [] walrus) { const char [] whale = walrus; } template dolphin(char [] fish) { // const char [] dolphin = fish[0..3]; // OK // const char [] dolphin = whale!(fish[0..(3)]); // OK // const char [] dolphin = whale!(fish[(0)..3]); // OK const char [] dolphin = whale!(fish[0..3]); // fails } //const char [] urchin = whale!("anenome"[0..3]); // OK const char [] urchin = dolphin!("anenome"); |
January 15, 2006 Re: [ .. ] isn't parsed correctly in nested template char[] parameters | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston Attachments: | Don Clugston schrieb am 2006-01-12: > The error message is: > found '..' when expecting ']' > > But it compiles correctly if parentheses are used around either of the > slice arguments. > It only seems to happen if the string itself comes from another char[] > parameter. > Tested on DMD 0.141, 0.142 and 0.143. > ----------------------------------------- > template whale(char [] walrus) > { > const char [] whale = walrus; > } > > template dolphin(char [] fish) > { > // const char [] dolphin = fish[0..3]; // OK > // const char [] dolphin = whale!(fish[0..(3)]); // OK > // const char [] dolphin = whale!(fish[(0)..3]); // OK > const char [] dolphin = whale!(fish[0..3]); // fails > } > > //const char [] urchin = whale!("anenome"[0..3]); // OK > const char [] urchin = dolphin!("anenome"); Added to DStress as http://dstress.kuehne.cn/run/t/template_24_A.d http://dstress.kuehne.cn/run/t/template_24_B.d http://dstress.kuehne.cn/run/t/template_24_C.d http://dstress.kuehne.cn/run/t/template_24_D.d http://dstress.kuehne.cn/run/t/template_24_E.d http://dstress.kuehne.cn/run/t/template_24_F.d http://dstress.kuehne.cn/run/t/template_24_G.d http://dstress.kuehne.cn/run/t/template_24_H.d http://dstress.kuehne.cn/run/t/template_24_I.d http://dstress.kuehne.cn/run/t/template_24_J.d Thomas |
Copyright © 1999-2021 by the D Language Foundation