Raku / old-issue-tracker

Tickets from RT
https://github.com/Raku/old-issue-tracker/issues
2 stars 1 forks source link

PRE submethods in a class don't check instance preconditions in Rakudo #3497

Open p6rt opened 10 years ago

p6rt commented 10 years ago

Migrated from rt.perl.org#122658 (status was 'open')

Searchable as RT122658$

p6rt commented 10 years ago

From @masak

\ m​: class IncList { has @​.values; submethod PRE { @​!values eqv @​!values.sort } }; say IncList.new(​:values(1, 5, 3)) \ rakudo-moar 5f9cd5​: OUTPUT«IncList.new(values => Array.new(1, 5, 3))␤» * masak submits NYI rakudobug \ m​: say [1, 5, 3] eqv [1, 5, 3].sort \ rakudo-moar 5f9cd5​: OUTPUT«False␤»

My expectation is that, since the condition is False, the object would fail the precondition at creation time.

p6rt commented 8 years ago

From @jnthn

On Sat Aug 30 21​:18​:35 2014, masak wrote​:

\ m​: class IncList { has @​.values; submethod PRE { @​!values eqv @​!values.sort } }; say IncList.new(​:values(1, 5, 3)) \ rakudo-moar 5f9cd5​: OUTPUT«IncList.new(values => Array.new(1, 5, 3))␤» * masak submits NYI rakudobug \ m​: say [1, 5, 3] eqv [1, 5, 3].sort \ rakudo-moar 5f9cd5​: OUTPUT«False␤»

My expectation is that, since the condition is False, the object would fail the precondition at creation time.

Support for PRE and POST submethods is deferred until 6.d or later. All uppercase names are semi-reserved anyway, so it won't really be a backwards compatibility issue to add this functionality later, and while it's nice to have, there's not huge demand for it.

Thus, removing it from the xmas list.

p6rt commented 8 years ago

The RT System itself - Status changed from 'new' to 'open'