Opened 4 years ago

#19553 new defect

Issue with convert maps for facade parents

Reported by: tscrim Owned by: tscrim
Priority: major Milestone: sage-6.10
Component: coercion Keywords:
Cc: nils, nbruin, SImonKing, jdemeyer, vbraun Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description

Consider the following:

sage: class Foo(Parent):
....:     def __init__(self):
....:         Parent.__init__(self, facade=True, category=Sets())
....:     def _element_constructor_(self, x):
....:         return int(x)
sage: F = Foo()
sage: F(5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: Cannot convert int to sage.structure.element.Element
sage: mor = F.convert_map_from(ZZ)
sage: mor
Conversion map:
  From: Integer Ring
  To:   <class '__main__.Foo_with_category'>
sage: mor(5)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
...
TypeError: Cannot convert int to sage.structure.element.Element

which comes from the coercion framework creating a DefaultConvertMap_unique whose _call_ method returns an int, since S is a facade for int's, which cannot be converted to an Element.

Change History (0)

Note: See TracTickets for help on using tickets.