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
  • #2677
Closed
Open
Issue created Jan 13, 2002 by Peter Bortas@zinoOwner

weirdness w/ternary operator (a?b:c)

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

Reported by Martin Stjernholm mast@roxen.com

From: "Robert J. Budzynski" <Robert.Budzynski@fuw.edu.pl>
Subject: weirdness w/ternary operator (a?b:c)
To: pike@roxen.com
Date: Sun Jan 13 02:12:14 2002 +0100

Pike v7.2 release 234 running Hilfe v2.0 (Incremental Pike Frontend)
> mixed foo(mixed x){return x?(write("FOO\n"),"FOO"):werror("BAR\n");}
> foo(1);
FOO
Result: 1
> foo(0);
BAR
Result: 0
> mixed fooo(mixed x){return
x?(write("FOO\n"),"FOO"):(werror("BAR\n"),"BAR");}
> fooo(0);
BAR
Result: "BAR"
> fooo(1);
FOO
Result: "FOO"

Note that while fooo() works correctly, the return value of foo(1) is bogus. Pike is getting confused when the third arg of the ternary operator (the `c' in a?b:c) is a call to a function of return type void.

Assignee
Assign to
Time tracking