#1133: MMD matching does not match 'scalar' with primitive types
-----------------------------+----------------------------------------------
Reporter: Austin_Hastings | Type: bug
Status: new | Priority: normal
Milestone: | Component: none
Version: 1.6.0 | Severity: medium
Keywords: | Lang:
Patch: | Platform:
-----------------------------+----------------------------------------------
When MMD is matching a primitive (int, float, str) argument, it knows
about autoboxing and supplies a 1-point manhattan penalty for requiring
autoboxing into one of the Scalar types (Integer, Float, etc.)
But MMD does not appear to know about 'scalar' as a superclass of the
Scalar types, since it is handing the autoboxing specially.
As a result, this code misbehaves:
{{{
.sub 'foo' :multi(['scalar'])
.param pmc x
say "Scalar!"
.end
.sub 'foo' :multi()
.param pmc x
$I0 = isa x, 'scalar'
print "Scalar? "
say $I0
.end
.sub 'main' :main
'foo'(1)
$P0 = box 1
'foo'($P0)
.end
}}}
While `foo(1)` is ''not'' considered a scalar, `foo(box(1))` ''is,'' which
is confusing. (And wrong, IMO.)
I suggest recoding the special-case processing for primitive types in
manhattan-distance so autobox is considered a "step" in the MRO below
'scalar' for Scalar types.
That is, the MRO for 'Integer' would be {Integer}->scalar->integer.
Alternatively, special-casing the 'scalar' PMC type as an extra builtin
would work, but smells like a dead fish.
--
Ticket URL: <https://trac.parrot.org/parrot/ticket/1133>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets