Menu

#30 Obscure "You have more than one..." error with templates

v6.x
closed
block (6)
5
2021-06-25
2018-05-17
No

Hi Zoltan,

I came across the obscure error "You have more than one block with name c1..." with a real-life block diagram. I cannot think of a good reason this is happening unless something is off with scopes. So I distilled the problem and reduced it to the block code included below.

I'm guessing it has something to do with the way multiple nested templates (which I do need) are eventually expanded and merged into the final object trees and scopes, and where references inside a template that look unambiguous, but cannot be uniquely resolved anymore because of this expansion.

There are dozens of ways to work around the issue, but I thought that I should report this anyway, since it might concern some fundamental issue you want to know about.

Please note that the error disappears when for example:

  • I change [top=c1] to [top=prev], the error disappears.
  • I remove the row from scenario1, scenario2 or both.
  • I give the row from scenario1, scenario2 or both an identifier.
  • I remove template from scenario1 and scenario2and don't do the last copy actions.

Kind regards,
Martijn

template box env {
  box c1 {
    box n1;
  }
  box c2 [top=c1] {
    box n1;
  }
}

template box frame {
  copy env as env1;
  copy env as env2;
}

template boxcol scenario1 {
  row {
    copy frame as step1;
    copy frame as step2;
  }
}

template boxcol scenario2 {
  row {
    copy frame as step1;
  }
}

copy scenario1 as a;
copy scenario2 as b;

Discussion

  • Zoltán Turányi

    • labels: --> block
    • status: open --> accepted
     
  • Zoltán Turányi

    Ok, thanks. This will take some time...

     
    • Zoltán Turányi

      And it did indeed...
      Will be fixed in 6.4.1

       
  • Zoltán Turányi

    • status: accepted --> closed