Warn when expander yields blocks that are known to be ignored

This is just a debugging tool, if this warning occurs it's an indication
of a bug in BAT.
This commit is contained in:
Sybren A. Stüvel 2021-07-27 16:38:07 +02:00
parent 74ae76cd73
commit 932283be65

View File

@ -49,9 +49,17 @@ def expand_block(
return
log.debug("Expanding block %r", block)
for dependency in expander(block):
if not dependency:
# Filter out falsy blocks, i.e. None values.
# Allowing expanders to yield None makes them more consise.
yield from filter(None, expander(block))
continue
if dependency.code == b"DATA":
log.warn(
"expander yielded block %s which will be ignored in later iteration",
dependency,
)
yield dependency
def dna_code(block_code: str):