Compile-time checking for %$obj{"key"} under ‘use fields’
authorFather Chrysostomos <sprout@cpan.org>
Tue, 12 Nov 2013 14:13:44 +0000 (06:13 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Thu, 14 Nov 2013 13:54:35 +0000 (05:54 -0800)
This single line of code also gives us shared hash key optimisa-
tions for free.

op.c
t/lib/croak/op

diff --git a/op.c b/op.c
index 625eabaf7c47163f9d212d3d36f91d5bbb987dc1..412a5ce787b4a3cdb5c00778dab5930af3a472a5 100644 (file)
--- a/op.c
+++ b/op.c
@@ -1935,6 +1935,7 @@ S_finalize_op(pTHX_ OP* o)
     case OP_HSLICE:
        S_scalar_slice_warning(aTHX_ o);
 
+    case OP_KVHSLICE:
        if (/* I bet there's always a pushmark... */
                (kid = cLISTOPo->op_first->op_sibling)->op_type != OP_LIST
              && kid->op_type != OP_CONST)
index 3ec418ffd4fb5eb03dd1a8695f63cd843beeafdd..4cc82af2f9cc6457abcce1f79827fceb396095fa 100644 (file)
@@ -43,6 +43,13 @@ my main $f;
 EXPECT
 No such class field "a" in variable $f of type main at - line 3.
 ########
+# NAME OP_KVHSLICE fields
+BEGIN { %FIELDS = qw(a 1 b 1); }
+my main $f;
+%$f{"a","c"};
+EXPECT
+No such class field "c" in variable $f of type main at - line 3.
+########
 # NAME delete BAD
 delete $x;
 EXPECT