octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug on octave 3.1.51+ with pkg install


From: John W. Eaton
Subject: Re: Bug on octave 3.1.51+ with pkg install
Date: Wed, 20 Aug 2008 15:59:34 -0400

On 20-Aug-2008, John W. Eaton wrote:

| On 18-Aug-2008, Jaroslav Hajek wrote:
| 
| | Since there is no reason to wrap the subfunction
| | is_architecture_dependent in an identity anonymous function, the
| | attached workaround should make the problem vanish (and it is not a
| | temporary solution).
| 
| I applied the changeset.
| 
| | Still, the underlying problem persists, as the subfunction seem to be
| | unreachable in an anonymous function. Not always, though: it seems to
| | work when pkg.m is copied into local directory. I'll try to submit a
| | new bug report for this.
| 
| Does anyone have a simpler test case that shows the problem?  That
| would help, but either way I'll try to look at this problem sometime
| this week.

I found a simpler case:

  function foo ()
    c = {-1, 0, 1};
    cellfun (@(x) sub2 (x), c)
    sub1 (c);
  endfunction
  function sub1 (c)
    cellfun (@(x) sub2 (x), c)
  endfunction
  function y = sub2 (x)
    y = x > 0;
  endfunction

I think the attached patch should solve the problem.

This code will probably have to change again in order to properly
handle nested functions (not planned until after 3.2).

jwe

# HG changeset patch
# User John W. Eaton <address@hidden>
# Date 1219262234 14400
# Node ID 24701aa75ecbe5f64da30b756890888a858ef029
# Parent  faf0abc5fd515423c7b95083b03260bdfcc6f777
scope fixes for anonymous and inline functions that appear inside subfunctions

diff --git a/src/ov-fcn-inline.cc b/src/ov-fcn-inline.cc
--- a/src/ov-fcn-inline.cc
+++ b/src/ov-fcn-inline.cc
@@ -91,7 +91,20 @@
          octave_user_function *uf = fcn.user_function_value ();
 
          if (uf)
-           uf->stash_parent_fcn_scope (octave_call_stack::current_scope ());
+           {
+             octave_function *curr_fcn = octave_call_stack::current ();
+
+             if (curr_fcn)
+               {
+                 symbol_table::scope_id parent_scope
+                   = curr_fcn->parent_fcn_scope ();
+
+                 if (parent_scope < 0)
+                   parent_scope = curr_fcn->scope ();
+       
+                 uf->stash_parent_fcn_scope (parent_scope);
+               }
+           }
        }
     }
 
diff --git a/src/pt-fcn-handle.cc b/src/pt-fcn-handle.cc
--- a/src/pt-fcn-handle.cc
+++ b/src/pt-fcn-handle.cc
@@ -114,7 +114,13 @@
   if (curr_fcn)
     {
       uf->stash_parent_fcn_name (curr_fcn->name ());
-      uf->stash_parent_fcn_scope (curr_fcn->scope ());
+
+      symbol_table::scope_id parent_scope = curr_fcn->parent_fcn_scope ();
+
+      if (parent_scope < 0)
+       parent_scope = curr_fcn->scope ();
+       
+      uf->stash_parent_fcn_scope (parent_scope);
     }
 
   uf->mark_as_inline_function ();

reply via email to

[Prev in Thread] Current Thread [Next in Thread]