# HG changeset patch # User John W. Eaton # Date 1332991304 14400 # Node ID 3f21c0c34b8f39c7255775336ecb819c207fe000 # Parent 6cc30975e2628a2fdc691e6cedcdd0e9fff8d76d check for function/file name mismatch when parsing class methods * oct-parse.yy (frob_function): Also check for and repair function name/file name mismatch when parsing class methods. * test/bug-36025: New test directory. * test/Makefile.am: Include bug-36025/module.mk. diff -r 6cc30975e262 -r 3f21c0c34b8f src/oct-parse.yy --- a/src/oct-parse.yy Wed Mar 28 12:59:46 2012 -0400 +++ b/src/oct-parse.yy Wed Mar 28 23:21:44 2012 -0400 @@ -2823,8 +2823,7 @@ // file. Matlab doesn't provide a diagnostic (it ignores the stated // name). if (! autoloading && reading_fcn_file - && (current_function_depth == 1 - && ! (parsing_subfunctions || lexer_flags.parsing_class_method))) + && current_function_depth == 1 && ! parsing_subfunctions) { // FIXME -- should curr_fcn_file_name already be // preprocessed when we get here? It seems to only be a diff -r 6cc30975e262 -r 3f21c0c34b8f test/Makefile.am --- a/test/Makefile.am Wed Mar 28 12:59:46 2012 -0400 +++ b/test/Makefile.am Wed Mar 28 23:21:44 2012 -0400 @@ -51,6 +51,7 @@ test_while.m include bug-35448/module.mk +include bug-36025/module.mk include classes/module.mk include class-concat/module.mk include ctor-vs-method/module.mk diff -r 6cc30975e262 -r 3f21c0c34b8f test/bug-36025/@testclass/one.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-36025/@testclass/one.m Wed Mar 28 23:21:44 2012 -0400 @@ -0,0 +1,4 @@ +% function ONE return item "X" + +function a=one(m) + a=m.x; diff -r 6cc30975e262 -r 3f21c0c34b8f test/bug-36025/@testclass/testclass.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-36025/@testclass/testclass.m Wed Mar 28 23:21:44 2012 -0400 @@ -0,0 +1,3 @@ +function m=testclass(x,y) +m=struct('x',x,'y',y); +m=class(m,"testclass"); diff -r 6cc30975e262 -r 3f21c0c34b8f test/bug-36025/@testclass/two.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-36025/@testclass/two.m Wed Mar 28 23:21:44 2012 -0400 @@ -0,0 +1,4 @@ +% function TWO returns item "Y" + +function a=one(m) + a=m.y; diff -r 6cc30975e262 -r 3f21c0c34b8f test/bug-36025/module.mk --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-36025/module.mk Wed Mar 28 23:21:44 2012 -0400 @@ -0,0 +1,7 @@ +bug_36025_FCN_FILES = \ + bug-36025/@testclass/one.m \ + bug-36025/@testclass/testclass.m \ + bug-36025/@testclass/two.m \ + bug-36025/test_bug_36025.m + +FCN_FILES += $(bug_36025_FCN_FILES) diff -r 6cc30975e262 -r 3f21c0c34b8f test/bug-36025/test_bug_36025.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/bug-36025/test_bug_36025.m Wed Mar 28 23:21:44 2012 -0400 @@ -0,0 +1,9 @@ +%!test +%! warning off Octave:function-name-clash +%! f = testclass (1, 2); +%! assert (one (f), 1); +%! assert (two (f), 2); +%! rehash (); +%! assert (one (f), 1); +%! assert (two (f), 2); +%! assert (two (f), 2);