bugGNU Octave - Bugs: bug #62928, Error sourcing file message when...

 
 

bug #62928: Error sourcing file message when script with embedded '.' in filename has syntax error

Submitter:  None
Submitted:  Sun 21 Aug 2022 02:43:06 AM UTC
   
 
Category:  Interpreter Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Unexpected Error or Warning
Status:  Patch Submitted Assigned to:  None
Originator Name:  Richard Lobb Originator Email:  -email is unavailable-
Open/Closed:  * Open Release:  * 6.4.0
Release:  Operating System:  * Any
Fixed Release:  None Planned Release:  10.1.0
* Mandatory Fields

Add a New Comment Rich Markup
   

Jump to the original submission

Fri 25 Oct 2024 11:10:04 PM UTC, comment #6: 

Attached is a changeset which appears to do the right thing.  No compilation warning, and no long message.

(file #56572)

Rik <rik5>
Group administrator
Fri 25 Oct 2024 10:57:16 PM UTC, comment #5: 

This looks fine.  The message is very long.  The code for it is in pt-eval.cc.


          std::string error_message = ee.message ();
          if (error_message.empty ())
            error (ee, "source: error sourcing file '%s'",
                   file_full_name.c_str ());
          else
            error (ee, "source: error sourcing file '%s': %s",
                   file_full_name.c_str (), error_message.c_str ());


The error message is not empty so the code takes the else branch.  Maybe we shouldn't bother to add the sourcing message if a non-empty message already exists?  I tried modifying the else branch to


            error (ee, error_message.c_str ());


and there is a compilation warning (so this is not perfect code), but this does produce just the message about the syntax error.

Rik <rik5>
Group administrator
Tue 24 Sep 2024 11:40:27 AM UTC, comment #4: 

I pushed the following change to the default branch of Octave:
https://hg.savannah.gnu.org/hgweb/octave/rev/9d8f1b357cf8

With it, I see the following when trying to source your example file:

error: source: error sourcing file '...\lsreg-js.m': syntax error near line 14, column 6 in file ...\lsreg-js.m


This is pretty long and repeats the full file path. But it is probably still more useful than the previous (short) error message.

This should be part of the next major version of Octave (probably 10.1.0).

Marking as ready for test.

Markus Mützel <mmuetzel>
Group administrator
Tue 24 Sep 2024 08:19:17 AM UTC, comment #3: 

`-` is an operator in Octave and cannot be part of a function or script name.
If I rename the file to `lsreg_js.m`, Octave shows the following error:

>> lsreg_js

error: parse error near line 14 of file .../lsreg_js.m

  syntax error

>>> sT = ???;       % Standard deviation of CPU time ("σ_T" in paper).


The error message for the file name containing characters that are invalid in a script or function name could be clearer though admittedly.

I still see the same error for a script containing "." in its file name with Octave 9.2.0. So, re-opening (be it just for a better error message).

Markus Mützel <mmuetzel>
Group administrator
Mon 23 Sep 2024 10:55:27 AM UTC, comment #2: 

I am running Octave 8.4.0 and STILL run into what seems to be this same problem: octave says only "error: source: error sourcing file" without saying WHICH error and where it is.

I just re-installed the new version of octave, and I did NOT rename the source file.   The file name does NOT have a "." in the name (but has a "-"). See it attached below. I know that the file has lots of syntax errors, but I cannot fix them if I don't know even where the first one is.

(file #56444)

Anonymous
Tue 23 Aug 2022 05:08:03 PM UTC, comment #1: 

Happily, this has already been fixed.  Please upgrade to the current stable version (7.2).  Below is a sample session


octave-7.2.0 junk.1.m
error: 'xxx' undefined near line 1, column 1
error: called from
    junk.1.m at line 1 column 1



Rik <rik5>
Group administrator
Sun 21 Aug 2022 02:43:06 AM UTC, original submission:  

With Octave 6.4.0 if you have a script called, say, junk.m with a syntax error and you run it with

octave --no-window-system junk.m

you get the correct error message, e.g. "error: parse error near line 1 .."

But if you rename the file to, say, junk.1.m and try to run that you instead get told

error: source: error sourcing file '<workingdir>/junk.1.m'

If there is no syntax error, the command works fine.

With version 5.2 of Octave you get both the expected syntax error report and the 'error sourcing file' message.

Sample terminal dialogue with Octave 6.4:

blah:~$ cat >junk.m
x = 10(;
blah:~$ octave --no-window-system junk.m
error: parse error near line 1 of file /home/xxx/junk.m

  syntax error

>>> x = 10(;

           ^
blah:~$ cp junk.m junk.1.m
blah:~$ octave --no-window-system junk.1.m
error: source: error sourcing file '/home/xxx/junk.1.m'





Anonymous

 

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

Attach Files:
   
   
Comment:
   

Attached Files
file #56572:  62928.cset added by rik5 (1013B - application/octet-stream)
file #56444:  lsreg-js.m added by None (3KiB - text/x-objcsrc)

 

Carbon-Copy List
  • -email is unavailable- added by mmuetzel (Posted a comment)
  • -email is unavailable- added by rik5 (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only group members can vote.

     

    Follow 11 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2024-10-25 rik5 Attached File- Added 62928.cset, #56572
        StatusReady For Test Patch Submitted
    2024-09-24 mmuetzel StatusConfirmed Ready For Test
        Operating SystemGNU/Linux Any
        Planned ReleaseNone 10.1.0
    2024-09-24 mmuetzel StatusFixed Confirmed
        Open/ClosedClosed Open
    2024-09-23 None Attached File- Added lsreg-js.m, #56444
    2022-08-23 rik5 StatusNone Fixed
        Open/ClosedOpen Closed
    2022-08-22 mmuetzel Dependencies- bugs #62931 is dependent

    Back to the top

    Powered by Savane 3.15-ef91.
    Corresponding source code