I was wondering about the semantics of coercion of non-numbers, so I experimented with the interactive Pugs on feather:

pugs> +"42"
42.0
pugs> +"x42"
0.0

I assume that pugs is assuming "no fail" in the interactive environment. However, Is "0.0" the correct answer, or should it be one of "undef", or "NaN"?


In my experiments, I also noticed:

pugs> my Int $a = "42"
"42"
pugs> $a.WHAT
::Str


It seems that the explicit type of $a is being ignored in the assignment. Am I right to assume this is simply a bug?

testcase (if someone with commit bits can add it):

{
  no fail;
  my Int $a = "not numeric";
  is $a.WHAT, ::Int, "coercion in initial assignment";
}

Reply via email to