[Bug 563] New: scripting support for array broken

For more infomation about this bug, visit
Summary: scripting support for array broken
Product: RTT
Version: rtt-trunk
Platform: All
OS/Version: All
Status: NEW
Severity: critical
Priority: P2
Component: Scripting
AssignedTo: orocos-dev [..] ...
ReportedBy: ruben [dot] smits [..] ...
CC: orocos-dev [..] ...
Estimated Hours: 0.0

I have some problems using the array in scripts:

i created the following program to test some stuff:
1 program ProgramScript{
2 var array test1(2)
3 var array test2(5,1.0)
4 var array test3(2.0,0.0,8.0)
5 var array test4 = array(6)
6 var array test5 = array(5,1.0)
7 var array test6 = array(2.0,0.0,8.0)
8 }

when loading the program i get syntax errors on line 3 and 4:

Parse error at line 3: Syntactic error: Closing brace expected (or could not
find out what this linemeans).
Parse error at line 4: Semantic error: Attempt to initialize array test3 with a
double, expected an integer expression.

after commenting these out i get the following:

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test1
Got :Listen.ProgramScript.test1
= {0, 0}

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test4
Got :Listen.ProgramScript.test4
= {0, 0}

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test5
Got :Listen.ProgramScript.test5
= {0, 0}

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test6
Got :Listen.ProgramScript.test6
= {0, 0}

This is absolutely not the desired behavior, apparently all arrays get the
capacity of the first one created.

removing the first tree constructors and thus only creating the last tree ones
shows that those way of constructing (taken from the scripting documentation)
just don't work:

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test4
Got :Listen.ProgramScript.test4
= {}

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test5
Got :Listen.ProgramScript.test5
= {}

In Task Deployer[S]. (Status of last Command : none )
(type 'ls' for context info) :Listen.ProgramScript.test6
Got :Listen.ProgramScript.test6
= {}

so then i tried something that is not documented in scripting manual:
program ProgramScript{
var array test4(2) = array(2)
var array test5(5) = array(5,1.0)
var array test6(3) = array(2.0,0.0,8.0)
}

doesn't work either

btw what the hell happened with the dot operators:

In Task Listen[R]. (Status of last Command : none )
(type 'ls' for context info) :ProgramScript.test1.size
Got :ProgramScript.test1.size
Syntactic error: From TaskContext 'Listen': Task 'Listen' has no task or object
'test1'.

In Task Listen[R]. (Status of last Command : none )
(type 'ls' for context info) :ProgramScript.test1().size
Got :ProgramScript.test1().size
= {0, 0, 0, 0, 0, 0, 0, 0}

only the second one works in the taskbrowser (the first one used to work too),
but not in scripting:
[...]
3 var double test1size = test1.size()
[...]

0.092 [ ERROR ][ProgramLoader::loadProgram] test.ops :Parse error at line 3:
Syntactic error: Expected an initialisation value of the variable.

My conclusion: something very wrong happened with the scripting support

[Bug 563] scripting support for array broken

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
Status|NEW |RESOLVED
Resolution| |FIXED

--- Comment #2 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-05 10:39:33 ---
$ svn di src/scripting/
Index: src/scripting/PeerParser.cpp
===================================================================
--- src/scripting/PeerParser.cpp (revision 29354)
+++ src/scripting/PeerParser.cpp (working copy)
@@ -178,7 +178,8 @@
// do not consume it though.
//cout << std::string(begin, end +10)< mlastobject = name;
- mcurobject = 0;
+ if (mfullpath)
+ mcurobject = 0; //when partial paths are OK, leave curobject
pointing to last valid object.
throw_(begin, peer_not_found );
}
}

This bug was introduced due to the fix for bug#557.
The unit tests did not cover dot operators...

$ svn ci tests/types_test.* src/scripting/PeerParser.cpp -m"Fixes bug #563:
scripting support for array broken
return last object of partial path if partial is ok.
"
Sending src/scripting/PeerParser.cpp
Sending tests/types_test.cpp
Sending tests/types_test.hpp
Transmitting file data ...
Committed revision 29361.

Ruben Smits's picture

[Bug 563] scripting support for array broken

On Thursday June 5 2008 10:39:33 Peter Soetens wrote:
> For more infomation about this bug, visit
>
>
> Peter Soetens
<peter [dot] soetens [..] ...> changed:
>
> What |Removed |Added
> --------------------------------------------------------------------------
> Status|NEW |RESOLVED
> Resolution| |FIXED
>
>
>
> --- Comment #2 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-05
> 10:39:33 --- $ svn di src/scripting/
> Index: src/scripting/PeerParser.cpp
> ===================================================================
> --- src/scripting/PeerParser.cpp (revision 29354)
> +++ src/scripting/PeerParser.cpp (working copy)
> @@ -178,7 +178,8 @@
> // do not consume it though.
> //cout << std::string(begin, end +10)< > mlastobject = name;
> - mcurobject = 0;
> + if (mfullpath)
> + mcurobject = 0; //when partial paths are OK, leave
> curobject pointing to last valid object.
> throw_(begin, peer_not_found );
> }
> }
>
> This bug was introduced due to the fix for bug#557.
> The unit tests did not cover dot operators...
>
> $ svn ci tests/types_test.* src/scripting/PeerParser.cpp -m"Fixes bug #563:
> scripting support for array broken
> return last object of partial path if partial is ok.
> "
> Sending src/scripting/PeerParser.cpp
> Sending tests/types_test.cpp
> Sending tests/types_test.hpp
> Transmitting file data ...
> Committed revision 29361.
>

the test passes, but i still get the same wrong behaviour when loading the
scripts in the deployer. I did a make clean;make;make install in rtt and ocl

Ruben
> --
> Configure bugmail:
> https://www.fmtc.be/bugzilla/orocos/userprefs.cgi?tab=email ------- You are
> receiving this mail because: -------
> You are on the CC list for the bug.
> You are the assignee for the bug.

Ruben Smits's picture

[Bug 563] scripting support for array broken

On Thursday June 5 2008 13:25:37 Ruben Smits wrote:
> On Thursday June 5 2008 10:39:33 Peter Soetens wrote:
> > For more infomation about this bug, visit
> >
> >
> > Peter Soetens
<peter [dot] soetens [..] ...> changed:
> >
> > What |Removed |Added
> >
> > -------------------------------------------------------------------------
> >- Status|NEW |RESOLVED
> > Resolution| |FIXED
> >
> >
> >
> > --- Comment #2 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-05
> > 10:39:33 --- $ svn di src/scripting/
> > Index: src/scripting/PeerParser.cpp
> > ===================================================================
> > --- src/scripting/PeerParser.cpp (revision 29354)
> > +++ src/scripting/PeerParser.cpp (working copy)
> > @@ -178,7 +178,8 @@
> > // do not consume it though.
> > //cout << std::string(begin, end +10)< > > mlastobject = name;
> > - mcurobject = 0;
> > + if (mfullpath)
> > + mcurobject = 0; //when partial paths are OK, leave
> > curobject pointing to last valid object.
> > throw_(begin, peer_not_found );
> > }
> > }
> >
> > This bug was introduced due to the fix for bug#557.
> > The unit tests did not cover dot operators...
> >
> > $ svn ci tests/types_test.* src/scripting/PeerParser.cpp -m"Fixes bug
> > #563: scripting support for array broken
> > return last object of partial path if partial is ok.
> > "
> > Sending src/scripting/PeerParser.cpp
> > Sending tests/types_test.cpp
> > Sending tests/types_test.hpp
> > Transmitting file data ...
> > Committed revision 29361.
>
> the test passes, but i still get the same wrong behaviour when loading the
> scripts in the deployer. I did a make clean;make;make install in rtt and
> ocl
Some more information: i'm trying to load the following script in the
deployer:
----
1 StateMachine test{
2 initial state Init{
3 run{
4 var array ar1(3)
5 var array ar2(2,3.0)
6 var array ar3(1.0,2.0,3.0)
7 }}
8 final state Final{}
9 }
10 RootMachine test test
----
and i get the following error:
[ ERROR ][ParserScriptingAccess::loadStateMachine] test.ops :Parse error at
line 5: Syntactic error: Closing brace expected (or could not find out what
this line means).

typing these constructors directly in the taskbrowser works perfectly

Ruben

[Bug 563] scripting support for array broken

On Thursday 05 June 2008 13:50:47 Ruben Smits wrote:
> On Thursday June 5 2008 13:25:37 Ruben Smits wrote:
> > On Thursday June 5 2008 10:39:33 Peter Soetens wrote:
> > > For more infomation about this bug, visit
> > >
> > >
> > > Peter Soetens
<peter [dot] soetens [..] ...> changed:
> > >
> > > What |Removed |Added
> > >
> > > -----------------------------------------------------------------------
> > >-- - Status|NEW |RESOLVED
> > > Resolution| |FIXED
> > >
> > >
> > >
> > > --- Comment #2 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-05
> > > 10:39:33 --- $ svn di src/scripting/
> > > Index: src/scripting/PeerParser.cpp
> > > ===================================================================
> > > --- src/scripting/PeerParser.cpp (revision 29354)
> > > +++ src/scripting/PeerParser.cpp (working copy)
> > > @@ -178,7 +178,8 @@
> > > // do not consume it though.
> > > //cout << std::string(begin, end +10)< > > > mlastobject = name;
> > > - mcurobject = 0;
> > > + if (mfullpath)
> > > + mcurobject = 0; //when partial paths are OK, leave
> > > curobject pointing to last valid object.
> > > throw_(begin, peer_not_found );
> > > }
> > > }
> > >
> > > This bug was introduced due to the fix for bug#557.
> > > The unit tests did not cover dot operators...
> > >
> > > $ svn ci tests/types_test.* src/scripting/PeerParser.cpp -m"Fixes bug
> > > #563: scripting support for array broken
> > > return last object of partial path if partial is ok.
> > > "
> > > Sending src/scripting/PeerParser.cpp
> > > Sending tests/types_test.cpp
> > > Sending tests/types_test.hpp
> > > Transmitting file data ...
> > > Committed revision 29361.
> >
> > the test passes, but i still get the same wrong behaviour when loading
> > the scripts in the deployer. I did a make clean;make;make install in rtt
> > and ocl
>
> Some more information: i'm trying to load the following script in the
> deployer:
> ----
> 1 StateMachine test{
> 2 initial state Init{
> 3 run{
> 4 var array ar1(3)

This line is correct

> 5 var array ar2(2,3.0)
> 6 var array ar3(1.0,2.0,3.0)

These two lines are not correct. The scripting language interpretes the first
case as a 'size hint' and creates an array of size 3. The second cases are
not accepted.

You need to write:

var array ar2(2) = array(2,3.0)
var array ar3(3) = array(1.0,2.0,3.0)

We should have used maybe [] for the size hint instead of ()...

Peter

> 7 }}
> 8 final state Final{}
> 9 }
> 10 RootMachine test test
> ----
> and i get the following error:
> [ ERROR ][ParserScriptingAccess::loadStateMachine] test.ops :Parse error
> at line 5: Syntactic error: Closing brace expected (or could not find out
> what this line means).
>
> typing these constructors directly in the taskbrowser works perfectly
>
> Ruben

[Bug 563] scripting support for array broken

For more infomation about this bug, visit

Peter Soetens
<peter [dot] soetens [..] ...> changed:

What |Removed |Added
--------------------------------------------------------------------------
CC| |peter [dot] soetens [..] ...

--- Comment #1 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-04 20:42:00 ---
(In reply to comment #0)
> I have some problems using the array in scripts:

Look at the tests/types_test.hpp|cpp files and add a unit test that
triggers this behaviour. Does the constructor syntax (array(...)) work
correctly in the TaskBrowser ?

Peter

Ruben Smits's picture

[Bug 563] scripting support for array broken

On Wednesday June 4 2008 20:42:00 Peter Soetens wrote:
> For more infomation about this bug, visit
>
>
> Peter Soetens
<peter [dot] soetens [..] ...> changed:
>
> What |Removed |Added
> --------------------------------------------------------------------------
> CC| |peter [dot] soetens [..] ...
>
>
>
> --- Comment #1 from Peter Soetens
<peter [dot] soetens [..] ...> 2008-06-04
> 20:42:00 --- (In reply to comment #0)
>
> > I have some problems using the array in scripts:
>
> Look at the tests/types_test.hpp|cpp files and add a unit test that
> triggers this behaviour. Does the constructor syntax (array(...)) work
> correctly in the TaskBrowser ?

The constructor syntax works correctly in the taskbrowser, the dot operators
don't.

Added following tests:
//30:
"var array ar1(12,2.0)"+
"do test.assert(ar1.size == 12)"+
"do test.assert(ar1[0] == 2.0)"+
"var array ar2 = array(5,3.0)"+
"do test.assert(ar2.size == 5)"+
"do test.assert(ar2[0] == 3.0)"+
"var array ar3(2.0,3.0,4.0)"+
"do test.assert(ar3.size == 3)"+
"do test.assert(ar3[0]==2.0)"+
"do test.assert(ar3[1]==3.0)"+
//40:
"do test.assert(ar3[2]==4.0)"+
"var array ar4 = array(2.0,3.0,4.0,5.0)"+
"do test.assert(ar4.size == 4)"+
"do test.assert(ar4[0]==2.0)"+
"do test.assert(ar4[1]==3.0)"+
"do test.assert(ar4[2]==4.0)"+
"do test.assert(ar4[3]==5.0)"+

Which gave me the following error:

Test command: /home/rsmits/orocos/rtt/build/tests/parser-test
Test timeout computed to be: 9.99988e+06
.F................

types_test.cpp:322:Assertion
Test name: TypesTest::testTypes
assertion failed
- Expression: false
- Parse error at line 30: Syntactic error: Closing brace expected (or could
not
find out what this line means).

I'll commit the complete test, i have no idea where i have to change stuff to
fix this, probably at some place that is recently changed because this worked
in past.

Ruben

> Peter
>
> --
> Configure bugmail:
> https://www.fmtc.be/bugzilla/orocos/userprefs.cgi?tab=email ------- You are
> receiving this mail because: -------
> You are on the CC list for the bug.
> You are the assignee for the bug.

[Bug 563] scripting support for array broken

On Thursday 05 June 2008 09:29:07 Ruben Smits wrote:
>
> The constructor syntax works correctly in the taskbrowser, the dot
> operators don't.
>
> Added following tests:
> //30:
> "var array ar1(12,2.0)"+
> "do test.assert(ar1.size == 12)"+
> "do test.assert(ar1[0] == 2.0)"+
> "var array ar2 = array(5,3.0)"+
> "do test.assert(ar2.size == 5)"+
> "do test.assert(ar2[0] == 3.0)"+
> "var array ar3(2.0,3.0,4.0)"+
> "do test.assert(ar3.size == 3)"+
> "do test.assert(ar3[0]==2.0)"+
> "do test.assert(ar3[1]==3.0)"+
> //40:
> "do test.assert(ar3[2]==4.0)"+
> "var array ar4 = array(2.0,3.0,4.0,5.0)"+
> "do test.assert(ar4.size == 4)"+
> "do test.assert(ar4[0]==2.0)"+
> "do test.assert(ar4[1]==3.0)"+
> "do test.assert(ar4[2]==4.0)"+
> "do test.assert(ar4[3]==5.0)"+

These tests are not correct. You omitted the \n... in practice you passed

var array ar1(12,2.0)do test.assert(ar1.size == 12)do test.assert(ar1[0]
==2.0)....

to the parser.

Peter

Ruben Smits's picture

[Bug 563] scripting support for array broken

On Thursday June 5 2008 09:38:12 Peter Soetens wrote:
> On Thursday 05 June 2008 09:29:07 Ruben Smits wrote:
> > The constructor syntax works correctly in the taskbrowser, the dot
> > operators don't.
> >
> > Added following tests:
> > //30:
> > "var array ar1(12,2.0)"+
> > "do test.assert(ar1.size == 12)"+
> > "do test.assert(ar1[0] == 2.0)"+
> > "var array ar2 = array(5,3.0)"+
> > "do test.assert(ar2.size == 5)"+
> > "do test.assert(ar2[0] == 3.0)"+
> > "var array ar3(2.0,3.0,4.0)"+
> > "do test.assert(ar3.size == 3)"+
> > "do test.assert(ar3[0]==2.0)"+
> > "do test.assert(ar3[1]==3.0)"+
> > //40:
> > "do test.assert(ar3[2]==4.0)"+
> > "var array ar4 = array(2.0,3.0,4.0,5.0)"+
> > "do test.assert(ar4.size == 4)"+
> > "do test.assert(ar4[0]==2.0)"+
> > "do test.assert(ar4[1]==3.0)"+
> > "do test.assert(ar4[2]==4.0)"+
> > "do test.assert(ar4[3]==5.0)"+
>
> These tests are not correct. You omitted the \n... in practice you passed

They are indeed not correct in the mail, but they are in the test ;) check the
commit if you want. Sorry for the confusion.

> var array ar1(12,2.0)do test.assert(ar1.size == 12)do test.assert(ar1[0]
> ==2.0)....
>
> to the parser.

So the bug is still out there ...

Ruben