Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid warnings on lazy load #6

Merged
merged 1 commit into from
Jun 16, 2019
Merged

Avoid warnings on lazy load #6

merged 1 commit into from
Jun 16, 2019

Conversation

bayashi
Copy link
Collaborator

@bayashi bayashi commented May 25, 2019

Generaly, CHECK phase executes on last of compiling module. But I want to use this module as lazy-loaded. So a procs of CHECK should be able to being called from outside. And I've got rid of warnings 'Too late to run CHECK block'.

If we would have a way to avoid warnings from outside, we don't need no warnings in it. I think that it'd be better to have warnings.

@coveralls
Copy link

coveralls commented May 25, 2019

Pull Request Test Coverage Report for Build 42

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 98.851%

Totals Coverage Status
Change from base Build 39: 0.03%
Covered Lines: 86
Relevant Lines: 87

💛 - Coveralls

1 similar comment
@coveralls
Copy link

Pull Request Test Coverage Report for Build 42

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.03%) to 98.851%

Totals Coverage Status
Change from base Build 39: 0.03%
Covered Lines: 86
Relevant Lines: 87

💛 - Coveralls

@kfly8
Copy link
Owner

kfly8 commented Jun 5, 2019

Thank you for the pull request!
I want to make it easier to debug if CHECK is called.

For example, I would like to do the following:

diff --git a/lib/Function/Return.pm b/lib/Function/Return.pm
index a24d453..79cbc17 100644
--- a/lib/Function/Return.pm
+++ b/lib/Function/Return.pm
@@ -170,7 +170,27 @@ sub _register_return_info {
     $metadata{$key} = $info;
 }
 
-sub CHECK {
+sub explain_check {
+    # TODO: more polite
+    my $dec = join ',', map {
+        my $sub = $_->{sub};
+        my $subname   = Sub::Util::subname($_->{sub});
+        $subname;
+    } @DECLARATIONS;
+
+    warn "Call Function::Return#CHECK. DECLARATIONS: $dec";
+}
+
+BEGIN {
+    no warnings 'void';
+
+    CHECK {
+        explain_check() if $ENV{FUNCTION_RETURN_EXPLAIN};
+        check_sub();
+    }
+}
+
+sub check_sub {
     for my $decl (@DECLARATIONS) {
         my ($pkg, $sub, $types)  = @$decl{qw(pkg sub types)};

@kfly8
Copy link
Owner

kfly8 commented Jun 16, 2019

I noticed that I could use B::Hooks::EndOfScope.
Now it seems to work as expected, even in the lazy case.

I will merge this p-r and then try to fix it.

@kfly8 kfly8 merged commit 233eb6f into kfly8:master Jun 16, 2019
@kfly8
Copy link
Owner

kfly8 commented Jun 16, 2019

Ref: #7

kfly8 added a commit that referenced this pull request Jun 16, 2019
Changelog diff is:

diff --git a/Changes b/Changes
index 6561978..56a6edc 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,12 @@ Revision history for Perl extension Function-Return

 {{$NEXT}}

+0.06 2019-06-16T22:11:25Z
+    - Support lazy load #7 #6
+    - [BUGFIX] Fix no_check option #8
+    - [IMCOMPATIBLE CHANGE] remove name option #9
+    - add attributes tests #10
+
 0.05 2019-02-18T01:06:31Z
     - Add import option `pkg` (bayashi) #5
     - Fix document
kfly8 added a commit that referenced this pull request Jun 19, 2019
Changelog diff is:

diff --git a/Changes b/Changes
index 56a6edc..771f921 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,10 @@ Revision history for Perl extension Function-Return

 {{$NEXT}}

+0.07 2019-06-19T13:15:07Z
+    - [BUGFIX] Fix check_sub #11
+    - Support `no_check` option globally #12
+
 0.06 2019-06-16T22:11:25Z
     - Support lazy load #7 #6
     - [BUGFIX] Fix no_check option #8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants