Bug 145 – Can't refer to global scope after a cast

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P3
Component
dmd
Product
D
Version
D1 (retired)
Platform
x86
OS
Windows
Creation time
2006-05-18T07:03:00Z
Last change time
2014-08-22T08:04:52Z
Keywords
rejects-valid
Assigned to
bugzilla
Creator
lio+bugzilla

Comments

Comment #0 by lio+bugzilla — 2006-05-18T07:03:53Z
#int somefunc(int i) { return i; } #class someclass{ #// int somefunc() {...} # uint otherfunc(){ # return cast(uint).somefunc(2); # } #} C:\dmd>dmd test.d test.d(5): found '(' when expecting ';' following 'return statement' test.d(5): found ')' when expecting ';' following 'statement' C:\dmd>dmd Digital Mars D Compiler v0.157 If ".somefunc" were in a module, "cast(uint)somemod.somefunc" works just fine.
Comment #1 by matti.niemenmaa+dbugzilla — 2006-05-18T07:11:54Z
Just wrap .somefunc(2) in brackets: int somefunc(int i) { return i; } class someclass{ // int somefunc() {...} uint otherfunc(){ return cast(uint)(.somefunc(2)); } } I guess it's still a bug, since the parser should be able to realise that we're not trying to, for instance, call a method of cast(uint)'s named somefunc. But it's not really that important.
Comment #2 by smjg — 2006-05-18T07:43:32Z
I was just trying to follow the grammar to see if it should be allowed! Indeed, .someFunc(2) is a UnaryExpression, so yes.
Comment #3 by thomas-dloop — 2006-05-19T11:46:00Z
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [email protected] schrieb am 2006-05-18: > #int somefunc(int i) { return i; } > #class someclass{ > #// int somefunc() {...} > # uint otherfunc(){ > # return cast(uint).somefunc(2); > # } > #} > > C:\dmd>dmd test.d > test.d(5): found '(' when expecting ';' following 'return statement' > test.d(5): found ')' when expecting ';' following 'statement' > > C:\dmd>dmd > Digital Mars D Compiler v0.157 > > If ".somefunc" were in a module, "cast(uint)somemod.somefunc" works just fine. Added to DStress as http://dstress.kuehne.cn/run/o/opModule_01_A.d http://dstress.kuehne.cn/run/o/opModule_01_B.d Thomas -----BEGIN PGP SIGNATURE----- iD8DBQFEbb843w+/yD4P9tIRAn6+AJ0eoNXdbxvYEmPOxlG7u78F5HBg/QCeN/ii omyrnfG0dfw94VVCgIEPp2w= =h6St -----END PGP SIGNATURE-----
Comment #4 by bugzilla — 2006-06-30T20:24:04Z
Fixed DMD 0.162
Comment #5 by github-bugzilla — 2014-07-23T09:41:20Z
Commit pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/b4335c9d3eae1640d42e152894b2b9ec95d5828d Merge pull request #3802 from ibuclaw/bug145 [2.066b] Issue 13194 - ICE when initializing static class members to void
Comment #6 by github-bugzilla — 2014-07-23T15:35:40Z
Commit pushed to 2.066 at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/6129d4b5baf84afd32ac3cafd35c60abad9c0bb6 Merge pull request #3802 from ibuclaw/bug145 [2.066b] Issue 13194 - ICE when initializing static class members to void
Comment #7 by github-bugzilla — 2014-08-22T08:04:52Z