Skip to content

A Generator's add_requirements get lost when used via cpp_stubs or Python's call() method #7044

@steven-johnson

Description

@steven-johnson

When you call Generator::add_requirement (in either C++ or Python), we add the requirements to a list in the Pipeline we create; then, when lowering, convert those into a series of AssertStmts at the top of the block.

A subtle issue here comes in when you want to re-use a Generator at language-composition time, either via cpp_stubs or via the equivalent call() method in our Python Generators: instead of returning the Pipeline, these return the output(s) as a list of Func, extracted from the Pipeline... so the requirements are lost, meaning a possibly-vital error check is now missing.

Thinking out loud: perhaps we should:

  • move the add_requirements method to Func
  • have Pipeline aggregate all the requirements in its output Funcs and emit them at the top of its block (taking care to remove duplicates)

@abadams -- what do you think?

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions