depgen: Add error for rate block name conflicts

This can occur during template expansion if the user is not careful in
ensuring that all generated blocks will have unique names.  The error was
not useful: it failed type validation, which results in an internal error in
the compiler (from the user's perspective) and outputs no useful information
to aid in debugging.

* src/current/include/depgen.xsl
  (preproc:depgen preproc:sym): User-friendly error if more than one rate
    element.
  [rate]: Allow multiple rate elements.
master
Mike Gerwitz 2017-11-29 13:19:41 -05:00
parent df4d976277
commit e52d6c1eb0
1 changed files with 7 additions and 1 deletions

View File

@ -275,9 +275,15 @@
<xsl:variable name="pkg" as="element( lv:package )"
select="root(.)" />
<xsl:variable name="rate" as="element( lv:rate )"
<xsl:variable name="rate" as="element( lv:rate )*"
select="$pkg/lv:rate[ @yields=$name ]" />
<xsl:if test="count( $rate ) gt 1">
<xsl:message terminate="yes"
select="'error: rate block name conflict:',
string( $rate/@yields[1] )" />
</xsl:if>
<xsl:apply-templates mode="preproc:depgen"
select="$rate" />
</xsl:template>