bugGNU Octave - Bugs: bug #34532, eval fails to throw exception when...

 
 

bug #34532: eval fails to throw exception when evaluating JSON-like string

Submitted by:  None
Submitted on:  Tue 11 Oct 2011 07:16:12 PM UTC  
 
Category: InterpreterSeverity: 3 - Normal
Priority: 5 - NormalItem Group: Incorrect Result
Status: InvalidAssigned to: None
Originator Name: Qianqian FangOriginator Email: -unavailable-
Open/Closed: ClosedRelease: dev
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.

 

Wed 12 Oct 2011 01:57:30 PM UTC, comment #2:

I see. Now I see that MATLAB failed in those expressions because double quote is not valid, not because the expressions are malformed. If I replace all " to '', MATLAB gives the same results as octave.

So, I agree this is not a bug. It can be closed now.

Qianqian Fang <fangq>
Wed 12 Oct 2011 12:55:08 PM UTC, comment #1:

Why should eval fail here?

Although a bit obscure, expressions like 'value':'New' are valid in both Octave and Matlab, so creating cell arrays from them is also valid, and concatenation of the single cell array with [] is also valid.

I don't see a bug here, except that Octave might issue a warning for colon expressions formed with characters.

John W. Eaton <jwe>
Project Administrator
Tue 11 Oct 2011 07:16:12 PM UTC, original submission:

here is an example:

octave:1> eval('[{"value":"New","onclick":"CreateNewDoc"}]')
ans =
{
[1,1] =
[1,2] =
}

I was expecting eval fails and throws an exception.

Some more strange results:

octave:5> eval('[{"test"}]')
ans =
{
[1,1] = test
}

octave:7> eval('[{"test":"t"}]')
ans =
{
[1,1] = t
}

octave:8> eval('[{"test":"aaa"}]')
ans =
{
[1,1] =
}

octave:10> eval('[{"test":"ttt"}]')
ans =
{
[1,1] = t
}

I don't really understand the rationale behind this. I discovered this issue as I am working on a JSON encoder/decoder for MATLAB/Octave, see http://iso2mesh.sf.net/cgi-bin/index.cgi?jsonlab

Anonymous

 

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

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by fangq (Posted a comment)
  • -unavailable- added by jwe (Posted a comment)
  • -unavailable- added by None (Submitted the item)
  •  

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

    Only project members can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Wed 12 Oct 2011 02:12:17 PM UTCjweStatusNone=>Invalid
      Open/ClosedOpen=>Closed

    Back to the top


    Powered by Savane 3.1-cleanup1