bool resolves to int(1..1)

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

Reported by KG Sterneberg kg@roxen.com

I get the following problem:


>pike bool-test.pike
int(1..1)
Bool value: 1
Bad argument 1 to foo(). Expected object | { bool = int(1..1) }.
bool-test.pike:9: /main()->foo(0)
bool-test.pike:5:
    /main()->main(1,({"/Users/kg/dev/learning/pike/bool-test.pike"}))

when running:


int main(int argc, array(string) argv)
{
  werror("%O\n", bool);
  foo(true);
  foo(false);
  return 0;
}

variant void foo(bool v) {
  werror("Bool value: %O\n", v);
}

variant void foo(object v) {
  werror("Object: %O\n", v);
}

Without variant it works fine:


int main(int argc, array(string) argv)
{
  werror("%O\n", bool);
  foo(true);
  foo(false);
  return 0;
}

void foo(bool v) {
  werror("Bool value: %O\n", v);
}
}

Possible solution (by Grubba): In master.pike, replace


enum bool { false=0, true=1 };

with


typedef int(0..1) bool;
enum { false=0, true=1 };