Thread overview
[Bug 145] New: Can't refer to global scope after a cast
May 18, 2006
d-bugmail
May 18, 2006
d-bugmail
May 18, 2006
d-bugmail
May 19, 2006
Thomas Kuehne
May 18, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=145

           Summary: Can't refer to global scope after a cast
           Product: D
           Version: 0.157
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla@digitalmars.com
        ReportedBy: lio@lunesu.com


#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.


-- 

May 18, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=145


deewiant@gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |minor
           Priority|P2                          |P3




------- Comment #1 from deewiant@gmail.com  2006-05-18 07:11 -------
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.


-- 

May 18, 2006
http://d.puremagic.com/bugzilla/show_bug.cgi?id=145


smjg@iname.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |smjg@iname.com
           Keywords|                            |rejects-valid




------- Comment #2 from smjg@iname.com  2006-05-18 07:43 -------
I was just trying to follow the grammar to see if it should be allowed! Indeed, .someFunc(2) is a UnaryExpression, so yes.


-- 

May 19, 2006
d-bugmail@puremagic.com 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