This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix for RT #8438: $tied->() doesn't call FETCH
[perl5.git] / t / op / tie.t
index ad3031a..38c5cff 100644 (file)
@@ -913,3 +913,19 @@ sub EXTEND   { }
 
 EXPECT
 ok
+########
+# RT 8438: Tied scalars don't call FETCH when subref is dereferenced
+
+sub TIESCALAR { bless {} }
+
+my $fetch = 0;
+my $called = 0;
+sub FETCH { $fetch++; sub { $called++ } }
+
+tie my $f, 'main';
+$f->(1) for 1,2;
+print "fetch=$fetch\ncalled=$called\n";
+
+EXPECT
+fetch=2
+called=2