bugGNU Octave - Bugs: bug #58780, 'source' throws unexpected syntax...


bug #58780: 'source' throws unexpected syntax error.

Submitted by:  Martin Castillo <castilma>
Submitted on:  Sat 18 Jul 2020 03:17:32 PM UTC  
Category:  Interpreter Severity:  2 - Minor
Priority:  3 - Low Item Group:  Unexpected Error or Warning
Status:  Confirmed Assigned to:  None
Originator Name:  Open/Closed:  Open
Release:  6.0.90 Operating System:  GNU/Linux

Add a New Comment (Rich Markup)

You are not logged in

Please log in, so followups can be emailed to you.


Mon 20 Jul 2020 05:46:03 AM UTC, comment #4: 

Thank you for your bug report.  I can confirm the issue for Octave 6 and 7.

ans = 713398d4a3c3

I do not think that it is super important to be fixed, but the interpreter acts a little weird here.  I cannot reliably say when "source" really parses the file and when not.  Maybe the documentation could be more verbose about it.



Parse and execute the contents of "file", where "file" is an absolute or relative path to a file.

In this case any call to "source foo" should error.

Kai Torben Ohlhus <siko1056>
Project Member
Sun 19 Jul 2020 10:42:00 PM UTC, comment #3: 

I was told I should paste this case, where I call source with the exact filename, too.

octave:2> source foo.m
parse error near line 1 of file /tmp/foo.m

  syntax error

>>> (1))


This 'works' as expected. There is no bug in this case.

Martin Castillo <castilma>
Sun 19 Jul 2020 10:38:40 PM UTC, comment #2: 

> source does not automatically append ".m" like run does.

This is exactly what I want to report. In the case, that foo.m exists but has a syntax error, source does add ".m" to the filename.

Martin Castillo <castilma>
Sat 18 Jul 2020 07:19:26 PM UTC, comment #1: 

If it's called foo.m, you would have to call "source foo.m" -- source does not automatically append ".m" like run does. I think that in your first invocation you indeed called "source foo.m", giving you the parse error, and in the second you called "source foo", receiving the error that "foo" does not exist (which would be correct).

Michael Leitner <mleitner>
Sat 18 Jul 2020 03:17:32 PM UTC, original submission:  

Sorry for weird title.

1) Create foo.m with a syntax error in the current directory.

2) try to source foo:
octave:1> source foo
parse error near line 1 of file /tmp/foo.m

  syntax error

>>> (1))


3) correct the file (remove last parantheses) and try to source again.

octave:1> source foo
error: no such file, '/tmp/foo'
error: source: error sourcing file '/tmp/foo'

So now it doesn't seem to look for foo.m anymore. But it's weird that it looked at it when it was wrong.
This surprised me a little bit, but might be wanted. I.e., function files can be sourced with the function name, but for source files, the whole filename needs to be passed. And so it has to read foo.m, to check, whether it is a function or not.

Martin Castillo <castilma>


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by siko1056 (Posted a comment)
  • -email is unavailable- added by mleitner (Posted a comment)
  • -email is unavailable- added by castilma (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only project members can vote.




    Follow 5 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2020-07-20 siko1056 CategoryNone => Interpreter
        Severity3 - Normal => 2 - Minor
        Priority5 - Normal => 3 - Low
        StatusNone => Confirmed
        Release5.2.0 => 6.0.90

    Back to the top

    Powered by Savane 3.5