Quantcast

Module default parameter scope rules changed?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Module default parameter scope rules changed?

nophead
I have some code that has a default module parameter that works in version 2016.10.04 (git 7e0935d) but doesn't work in 2017.01.20.

foot = [25, 12, 3, 2, M4_cap_screw, 10];

module foot_assembly(t, type = foot) {
...
}

When this module is used by another module and foot_assembly() is called then foot is undefined. So it seems that the scope lookup rules have changed recently. Obviously foot is defined where foot_assembly is defined but it isn't where it is called.

Which version is correct? Which scope should default parameters be looked up in? Seems to me it should be static scope, so this is a regression.


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

Re: Module default parameter scope rules changed?

kintel
Administrator
Thanks for the report!

This is most definitely a regression.
I’ve created a new issue: https://github.com/openscad/openscad/issues/1923

I’m surprised we don’t have a test for this, but that will change soon :)

FYI: Any snapshot 2016.10.16 or older should work.

 -Marius

> On Jan 30, 2017, at 06:56, nop head <[hidden email]> wrote:
>
> I have some code that has a default module parameter that works in version 2016.10.04 (git 7e0935d) but doesn't work in 2017.01.20.
>
> foot = [25, 12, 3, 2, M4_cap_screw, 10];
>
> module foot_assembly(t, type = foot) {
> ...
> }
>
> When this module is used by another module and foot_assembly() is called then foot is undefined. So it seems that the scope lookup rules have changed recently. Obviously foot is defined where foot_assembly is defined but it isn't where it is called.
>
> Which version is correct? Which scope should default parameters be looked up in? Seems to me it should be static scope, so this is a regression.
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


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