Mercurial > hg > octave-nkf
changeset 14507:3f21c0c34b8f
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.
author | John W. Eaton <jwe@octave.org> |
---|---|
date | Wed, 28 Mar 2012 23:21:44 -0400 |
parents | 6cc30975e262 |
children | 0901f926ed50 |
files | src/oct-parse.yy test/Makefile.am test/bug-36025/@testclass/one.m test/bug-36025/@testclass/testclass.m test/bug-36025/@testclass/two.m test/bug-36025/module.mk test/bug-36025/test_bug_36025.m |
diffstat | 7 files changed, 29 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/oct-parse.yy +++ b/src/oct-parse.yy @@ -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
--- a/test/Makefile.am +++ b/test/Makefile.am @@ -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
new file mode 100644 --- /dev/null +++ b/test/bug-36025/@testclass/one.m @@ -0,0 +1,4 @@ +% function ONE return item "X" + +function a=one(m) + a=m.x;
new file mode 100644 --- /dev/null +++ b/test/bug-36025/@testclass/testclass.m @@ -0,0 +1,3 @@ +function m=testclass(x,y) +m=struct('x',x,'y',y); +m=class(m,"testclass");
new file mode 100644 --- /dev/null +++ b/test/bug-36025/@testclass/two.m @@ -0,0 +1,4 @@ +% function TWO returns item "Y" + +function a=one(m) + a=m.y;
new file mode 100644 --- /dev/null +++ b/test/bug-36025/module.mk @@ -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)
new file mode 100644 --- /dev/null +++ b/test/bug-36025/test_bug_36025.m @@ -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);