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
  • #4534
Closed
Open
Issue created May 08, 2008 by Peter Bortas@zinoOwner

Confusing type error messages

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

Reported by Martin Stjernholm mast@roxen.com

Given this code:

  class X1 {
    string foo;
  }

  class X2 {
    array(string) foo;
  }

  class Y1 {
    void bar (X1 x);
  }

  class Y2 {
    void bar (X2 x);
  }

Y2 gnu (Y1 y) {return y;}

The compiler emits this error:

  foo.pike:17:Wrong return type.
  foo.pike:17:Expected: { Y2 = object(implements foo()->Y2) }
  foo.pike:17:Got     : { Y1 = object(implements foo()->Y1) }
  foo.pike:17:Identifier bar is incompatible.
  foo.pike:17:Expected: function({ X2 = object(implements foo()->X2) } : void)
  foo.pike:17:Got     : function({ X1 = object(implements foo()->X1) } : void)
  foo.pike:17:Identifier foo is incompatible.
  foo.pike:17:Expected: array(string)
  foo.pike:17:Got     : string

This provides nice info, but the message "Identifier foo is incompatible" could be more clear in where it has found foo, e.g. something like "Identifier foo in objects X1/X2 in argument 1 is incompatible". (In my real world case there was a foo in X1/X2 too which made it more confusing.)

Btw, an idle idea I got is to use the line info to point to the declarations:

  foo.pike:17:Wrong return type.
  foo.pike:17:Expected: { Y2 = object(implements foo()->Y2) }
  foo.pike:17:Got     : { Y1 = object(implements foo()->Y1) }
  foo.pike:17:Identifier bar in objects Y2/Y1 is incompatible.
  foo.pike:14:Expected: function({ X2 = object(implements foo()->X2) } : void)
  foo.pike:10:Got     : function({ X1 = object(implements foo()->X1) } : void)
  foo.pike:17:Identifier foo in objects X2/X1 in argument 1 is incompatible.
  foo.pike:6:Expected: array(string)
  foo.pike:2:Got     : string
Assignee
Assign to
Time tracking