felix-hilden / sphinx-codeautolink

Automatic links from code examples to reference documentation
https://sphinx-codeautolink.rtfd.io
MIT License
58 stars 9 forks source link

Match-case overriding used variable is handled incorrectly #114

Open felix-hilden opened 2 years ago

felix-hilden commented 2 years ago

When implementing match support in #110 I ran into very hard to navigate issues, which led me to introduce two X-fails to the test suite. The problem is:

Match statements reference and assign multiple values simultaneously. This violates our assumptions quite profoundly, since references and assignments are handled entirely sequentially and generating references relies on the value being assigned in "scope". What's more, the whole nested match is "executed" at once.

I experimented with delaying assignments, effectively generating batches. But it was unsuccessful. I suspect to get this to work, we'll have to either change our architecture significantly, or write a custom assignment handler just for match.