POV-Ray / povray

The Persistence of Vision Raytracer: http://www.povray.org/
GNU Affero General Public License v3.0
1.35k stars 282 forks source link

Port of FS335 - macro works in variable but not in array #289

Open wfpokorny opened 7 years ago

wfpokorny commented 7 years ago

Port of FS335 - macro works in variable but not in array

http://bugs.povray.org/task/335 (Mike H (SharkD))

(Behavior unchanged to 3.7.2 master. Created test SDL at bottom)


Details:

This doesn' work:

#declare pavement_object = array[2]
{

object {trash_can_macro()             scale 3/4           translate -x * 1/2},
object {potted_plant_macro(_CT_rand2) scale 3/4 scale 3/2 translate -x * 1/2}

}

This does work:

#declare trash_can_object = object {trash_can_macro()};
#declare potted_plant_object = object {potted_plant_macro(_CT_rand2)};
#declare pavement_object = array[2]
{

object {trash_can_object    scale 3/4           translate -x * 1/2},
object {potted_plant_object scale 3/4 scale 3/2 translate -x * 1/2}

}

Logically, I cannot see a reason for this to be so.

//-------------------------- Test SDL start -------------------
#macro trash_can_macro()
    sphere { 0, 1 }
#end

#macro potted_plant_macro(_CT_rand2)
    sphere { 0, _CT_rand2 }
#end

// ------- Works --------
#declare _CT_rand2=1;
#declare trash_can_object    = object {trash_can_macro()};
#declare potted_plant_object = object {potted_plant_macro(_CT_rand2)};
#declare pavement_object = array[2]
{

object {trash_can_object    scale 3/4           translate -x * 1/2},
object {potted_plant_object scale 3/4 scale 3/2 translate -x * 1/2}

}

// ------- Fails --------
#declare pavement_object2 = array[2]
{

object {trash_can_macro()             scale 3/4           translate -x * 1/2},
object {potted_plant_macro(_CT_rand2) scale 3/4 scale 3/2 translate -x * 1/2}

}
//-------------------------- Test SDL end -------------------
c-lipka commented 3 years ago

For the records: As this is a parser issue, and doesn't causes a crash, I presume we don't even want to touch it with a 10-foot pole while preparing for v3.8.0 release proper.

wfpokorny commented 3 years ago

Agree - not for v3.8.0.