Assembly blocks followed by other Solidity instructions are treated as invalid

Related to https://github.com/ethereum/solidity/pull/11420.

The lexer has issues trying to process some of the snippets from Solidity docs. For example the micropayment example. The problematic part is:

        assembly {
            // first 32 bytes, after the length prefix.
            r := mload(add(sig, 32))
            // second 32 bytes.
            s := mload(add(sig, 64))
            // final byte (first byte of the next 32 bytes).
            v := byte(0, mload(add(sig, 96)))
        }

        return (v, r, s);

I noticed it after upgrading to Sphinx 4.0.2 and updating the add_lexer() call to use a lexer class rather than a lexer instance. When it gets a class, Sphinx no longer suppresses syntax errors in snippets and the one above results in WARNING: Could not lex literal_block as "Solidity". Highlighting skipped.. The warning disappears only when I remove either the assembly block or the return after it. It looks like the problem is in the lexer and change in Sphinx only made it visible now.

Assignee Loading
Time tracking Loading