Unaccountable warning

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Unaccountable warning

Ronaldo
Running:

function foo() = 
  [for( i = 0;
        i < 1;
        assert(i<1),
        i = i+1 ) i];
  
echo(foo());

I got:

Compiling design (CSG Tree generation)...

WARNING: Assignment without variable name undef, in file OpenSCAD-2019.01-RC4, line 2

ECHO: [0]


Line 2 is the line of the "for". Without the assert(), no message is issued.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Unaccountable warning

tp3
On 10.05.19 20:08, Ronaldo Persiano wrote:
> Line 2 is the line of the "for". Without the assert(), > no message is issued.

The message is correct. It's caused by the "," after the assert().

Moving the assert into the assignment of i it should work without
warning.

     function foo() =
       [for( i = 0;
             i < 1;
             i = assert(i<1) i+1 ) i];

ciao,
   Torsten.

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten
Reply | Threaded
Open this post in threaded view
|

Re: Unaccountable warning

Ronaldo


The message is correct. It's caused by the "," after the assert().

Moving the assert into the assignment of i it should work without
warning.

     function foo() =
       [for( i = 0;
             i < 1;
             i = assert(i<1) i+1 ) i];

But, the following works without any warning:

function foo2() =
  let( i = 0,
       assert(i<1),
       j = 1 )
  j;

What that warning means?

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
tp3
Reply | Threaded
Open this post in threaded view
|

Re: Unaccountable warning

tp3
On 10.05.19 21:57, Ronaldo Persiano wrote:
> What that warning means?

I guess that just means that the warning check is missing
in let().

In both cases the parser generates an assignment list:

lvalue1 = rvalue1, lvalue2 = rvalue2

The warning means that one of the lvalues does not have
a name. The parser allows that currently as it's reusing
the structure used for method calls where a missing
lvalue simply means it's a positional parameter like in
cube([1, 2, 3], center = true);

ciao,
   Torsten.


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
-- Torsten