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 105
    • Issues 105
    • 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
  • Collapse sidebar
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
  • pikelang
  • pikepike
  • Issues
  • #4534

Closed
Open
Opened 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
Pike 7.8
Milestone
Pike 7.8
Assign milestone
Time tracking
None
Due date
None
Reference: pikelang/pike#4534