Thread overview | ||||||
---|---|---|---|---|---|---|
|
October 24, 2005 needThis() bug | ||||
---|---|---|---|---|
| ||||
Hi,
The following code is wrong and makes the compiler crash:
------ CODE ------
class FOO{
struct S {
int a;
}
S st;
static int f( int a ){
return st.a;
}
}
------ CODE ------
Execution:
dmd bug.d
dmd: tocsym.c:142: virtual Symbol* VarDeclaration::toSymbol(): Assertion `!needThis()' failed.
Abgebrochen
Tiago
--
Tiago Gasiba (MSc.) - http://www.gasiba.de
Everything should be made as simple as possible, but not simpler.
|
October 25, 2005 Re: needThis() bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba | Hi.. It's seems a compile error: "st" is a member of the class FOO. You can't reference a member inside a static method, since the static methods has no "this" to work on. You need an instance of FOO to be able to access "st". Unfriendly error message though. L. "Tiago Gasiba" <tiago.gasiba@gmail.com> wrote in message news:dji2d3$acl$1@digitaldaemon.com... > Hi, > > The following code is wrong and makes the compiler crash: > > ------ CODE ------ > class FOO{ > struct S { > int a; > } > > S st; > > static int f( int a ){ > return st.a; > } > } > ------ CODE ------ > > Execution: > dmd bug.d > dmd: tocsym.c:142: virtual Symbol* VarDeclaration::toSymbol(): Assertion > `!needThis()' failed. > Abgebrochen > > Tiago > > -- > Tiago Gasiba (MSc.) - http://www.gasiba.de > Everything should be made as simple as possible, but not simpler. |
October 26, 2005 Re: needThis() bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Lionello Lunesu | Lionello Lunesu escribió: > Hi.. > > It's seems a compile error: "st" is a member of the class FOO. You can't reference a member inside a static method, since the static methods has no "this" to work on. You need an instance of FOO to be able to access "st". > That's why he said "the following code is wrong" > Unfriendly error message though. > That's the bug: it shouldn't crash the compiler. > L. > > "Tiago Gasiba" <tiago.gasiba@gmail.com> wrote in message news:dji2d3$acl$1@digitaldaemon.com... > >>Hi, >> >>The following code is wrong and makes the compiler crash: >> >>------ CODE ------ >>class FOO{ >> struct S { >> int a; >> } >> >> S st; >> >> static int f( int a ){ >> return st.a; >> } >>} >>------ CODE ------ >> >>Execution: >>dmd bug.d >>dmd: tocsym.c:142: virtual Symbol* VarDeclaration::toSymbol(): Assertion `!needThis()' failed. >>Abgebrochen >> >>Tiago >> >>-- >>Tiago Gasiba (MSc.) - http://www.gasiba.de >>Everything should be made as simple as possible, but not simpler. > > > -- Carlos Santander Bernal |
October 28, 2005 Re: needThis() bug | ||||
---|---|---|---|---|
| ||||
Posted in reply to Tiago Gasiba Attachments: | Tiago Gasiba schrieb am 2005-10-24: > Hi, > > The following code is wrong and makes the compiler crash: > > ------ CODE ------ > class FOO{ > struct S { > int a; > } > > S st; > > static int f( int a ){ > return st.a; > } > } > ------ CODE ------ > > Execution: > dmd bug.d > dmd: tocsym.c:142: virtual Symbol* VarDeclaration::toSymbol(): Assertion `!needThis()' failed. > Abgebrochen > > Tiago Added to DStress as http://dstress.kuehne.cn/nocompile/b/bug_tocsym_142_A.d http://dstress.kuehne.cn/nocompile/b/bug_tocsym_142_B.d http://dstress.kuehne.cn/nocompile/b/bug_tocsym_142_C.d http://dstress.kuehne.cn/nocompile/b/bug_tocsym_142_D.d Thomas |
Copyright © 1999-2021 by the D Language Foundation