Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • pike pike
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 104
    • Issues 104
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • pikelang
  • pikepike
  • Issues
  • #6573
Closed
Open
Issue created Oct 21, 2012 by Peter Bortas@zinoOwner

It should be possible to inherit "fake" classes

Imported from http://bugzilla.roxen.com/bugzilla/show_bug.cgi?id=6573

Reported by @marcus

It is possible to use the name of a "fake" class (really an object) when declaring a variable. However, when instead declaring an inherit the behaviour is not the expected.

Example:

---8<--- A.pmod ---8<--- static class Meta(string name) { string a() { return "+"+name; }

static class I(string value) { string a() { return "-"+name+":"+value; } int x() { return 0; } }

static program cast(string type) { return type=="program" && I; }

  static I `()(string v)
  {
    return I(v);
  }
}

Meta B = Meta("B");
---8<---

---8<--- b.pike ---8<---
import .A;

class C { inherit B; }

void main()
{
  B b = B("*");
  C c = C("%");
  write("%O %O\n", _typeof(b)<=typeof(b), b->a());
  write("%O %O\n", _typeof(c)<=typeof(b), c->a());
}
---8<---

Running b.pike gives the output

1 "-B:*" 0 "+%"

But the expected output is

1 "-B:*" 1 "-B:%"

compiler_do_inherit needs to check either the `() lfun (which is what the variable declaration does) or the cast lfun instead of just doing object_program().

Assignee
Assign to
Time tracking