Skip to content

GitLab

  • Projects
  • Groups
  • Snippets
  • Help
    • Loading...
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
pike
pike
  • Project overview
    • Project overview
    • Details
    • Activity
    • Releases
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 109
    • Issues 109
    • List
    • Boards
    • Labels
    • Service Desk
    • Milestones
  • Merge Requests 0
    • Merge Requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Operations
    • Operations
    • Incidents
    • Environments
  • Analytics
    • Analytics
    • CI/CD
    • Repository
    • Value Stream
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Members
    • Members
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pikelang
  • pikepike
  • Issues
  • #8009

Closed
Open
Created Mar 23, 2017 by Peter Bortas@zinoOwner

Declaration order for nested classes matters - should not!

Imported from https://youtrack.roxen.com/issue/PIKE-9

Reported by KG Sterneberg kg@roxen.com

The following code does not work (but it should):


int main(int argc, array(string) argv)
{
  Outer outer = Outer();
  Outer.Nested n = outer->get_nested();
  n->hello_world();
}

class Outer
{
  Nested get_nested()
  {
    return Nested();
  }

  class Nested
  {
    void hello_world() { werror("Hello World!\n"); }
  }
} 

Running it:


>pike tmp.pike
tmp.pike:4:Indexing on illegal type.
tmp.pike:4:Got     : zero.
tmp.pike:4:Index   : string(78..116).
tmp.pike:4:Expected constant expression.
Pike: Failed to compile script.

Moving "class Outer" above main solves the problem. However the order should not matter!

Assignee
Assign to
None
Milestone
None
Assign milestone
Time tracking
None
Due date
None