[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #49743] Two-input version of `eval` fails for
From: |
Luis Mendo |
Subject: |
[Octave-bug-tracker] [bug #49743] Two-input version of `eval` fails for certain inputs |
Date: |
Wed, 30 Nov 2016 15:12:24 +0000 (UTC) |
User-agent: |
Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2840.99 Safari/537.36 |
URL:
<http://savannah.gnu.org/bugs/?49743>
Summary: Two-input version of `eval` fails for certain inputs
Project: GNU Octave
Submitted by: lmendo
Submitted on: Wed Nov 30 15:12:22 2016
Category: Octave Function
Severity: 3 - Normal
Priority: 5 - Normal
Item Group: Incorrect Result
Status: None
Assigned to: None
Originator Name: Luis Mendo
Originator Email:
Open/Closed: Open
Discussion Lock: Any
Release: 4.0.0
Operating System: Any
_______________________________________________________
Details:
The two-input version of `eval` seems to be buggy. Try for example:
eval("s = ( +2 ( +2 ) +2 ) +2", "disp('Wrong input')")
That string should give an error when eval'ed, which should be caught. But
that's not the case: the above does nothing (no error, no displaying `Wrong
input` as it should). In fact, it seems to do worse than nothing: subsequent
statements are ignored. Try for example
eval("s = ( +2 ( +2 ) +2 ) +2", "disp('Wrong input')"); disp('Next
statement')
The explicit version does work:
try eval("s = ( +2 ( +2 ) +2 ) +2"); catch disp("Wrong input"); end;
disp('Next statement')
correctly displays `Wrong input` and then `Next statement`.
This bug happens in Octave 4.0.0, at least on Windows 7 and on Linux (tested
on https://octave-online.net/). I haven't tried Octave 4.2.
This also affects `str2num` (because it internally uses the two-input version
of `eval`). Try for example
s = str2num('( +2 ( +2 ) +2 ) +2'); whos s; disp("Next statement")
To fix `str2num`, simply replace line
eval (s, "m = []; state = false;");
by
try eval(s); catch m = []; state = false; end
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?49743>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/
- [Octave-bug-tracker] [bug #49743] Two-input version of `eval` fails for certain inputs,
Luis Mendo <=