If we're going to retain optional warnings, we should take advantage of
them.  The attached patch adds an optional warning to the Undef PMC when
stringifying it.  It's simple to add similar warnings when numifying and
intifying it.  Those are the only places where the warning makes sense
to me.

-- c
=== src/pmc/undef.pmc
==================================================================
--- src/pmc/undef.pmc	(revision 32053)
+++ src/pmc/undef.pmc	(local)
@@ -148,6 +148,9 @@
 */
 
     VTABLE STRING *get_string() {
+        Parrot_warn(interp, PARROT_WARNINGS_UNDEF_FLAG,
+            "Stringifying an Undef PMC");
+
         return string_make_empty(INTERP, enum_stringrep_one, 0);
     }
 
=== t/pmc/sub.t
==================================================================
--- t/pmc/sub.t	(revision 32053)
+++ t/pmc/sub.t	(local)
@@ -751,9 +751,7 @@
 back
 OUTPUT
 
-# This is the behavior of Parrot 0.4.3
-# RT #46817 Should there be a warning ?
-pir_output_is( <<'CODE', '', 'warn on in main' );
+pir_output_like( <<'CODE', '/Stringifying an Undef PMC/', 'warn on in main' );
 .sub _main :main
 .include "warnings.pasm"
     warningson .PARROT_WARNINGS_UNDEF_FLAG
@@ -780,10 +778,7 @@
 ok
 OUTPUT
 
-# RT #46819 This is the behavior of Parrot 0.4.3
-# It looks like core PMCs never emit warning.
-# Look in perlundef.t for a more sane test of 'warningson' in subs
-pir_output_is( <<'CODE', <<'OUTPUT', "warn on in sub, turn off in f2" );
+pir_output_like( <<'CODE', <<'OUTPUT', "warn on in sub, turn off in f2" );
 .sub _main :main
 .include "warnings.pasm"
     _f1()
@@ -802,8 +797,10 @@
     warningsoff .PARROT_WARNINGS_UNDEF_FLAG
 .end
 CODE
+/Stringifying an Undef PMC
+.*
 back
-ok
+ok/
 OUTPUT
 
 pasm_output_is( <<'CODE', <<'OUTPUT', "sub names" );
_______________________________________________
http://lists.parrot.org/mailman/listinfo/parrot-dev

Reply via email to