function nesttst
  disp('main function')
  a = 1;
  nested(2)
  function z = nested(x)
    disp('nested')           
    z = a+x;
    quad(@(q) nested2(q,a),z,1)    

    ## nested function works, as long as disp is not called.
    ##{
    function y = nested2(x,a)
      ## disp() statement causes internal error in Octave.
      ## commenting it out here will all code to proceed
      disp ('nested2');
      y = a.*sin(x);
    endfunction
    ##}
  end
end

## Uncomment subfunction to see that this works, even with disp() statement.
#{
 function y = nested2(x,a)
 disp('nested2')
 y = a.*sin(x);
 end
#}
