Skip to content

fix(astimport): accept sun/trx subdenominations in --import-ast#124

Merged
CodeNinjaEvan merged 1 commit into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-astimport-subdenomination
Jun 26, 2026
Merged

fix(astimport): accept sun/trx subdenominations in --import-ast#124
CodeNinjaEvan merged 1 commit into
tronprotocol:release_0.8.28from
yanghang8612:fix/tron-astimport-subdenomination

Conversation

@yanghang8612

Copy link
Copy Markdown

Summary

--import-ast aborts on any contract that uses a TRON sun / trx literal, because the importer does not recognise those subdenominations.

The bug

ASTJsonExporter serialises the sun / trx subdenominations (via the generic TokenTraits::toString), but ASTJsonImporter::subdenomination() hardcodes only the upstream units (weiyears) and astAssert(false, "Unknown subdenomination") on anything else. So exporting and re-importing a contract with a TRX literal fails:

contract C {
    function f() public pure returns (uint) {
        return 1 trx;
    }
}
$ solc --import-ast export.json
Error: Failed to import AST: Unknown subdenomination

This breaks any AST round-trip tooling (--ast-compact-json--import-ast) for TRON contracts using trx / sun units.

The fix

Add the sun and trx cases to ASTJsonImporter::subdenomination(), mapping to Literal::SubDenomination::Sun / Trx — the same enum values the exporter already emits — placed alongside ether to mirror the export ordering.

Targets release_0.8.28.

🤖 Generated with Claude Code

The exporter emits sun/trx but the importer rejected them, aborting
--import-ast on any contract with a TRX literal.
@github-actions

Copy link
Copy Markdown

Thank you for your contribution to the Solidity compiler! A team member will follow up shortly.

If you haven't read our contributing guidelines and our review checklist before, please do it now, this makes the reviewing process and accepting your contribution smoother.

If you have any questions or need our help, feel free to post them in the PR or talk to us directly on the #solidity-dev channel on Matrix.

@yanghang8612 yanghang8612 marked this pull request as ready for review June 25, 2026 13:08
@CodeNinjaEvan CodeNinjaEvan merged commit 59ac1cc into tronprotocol:release_0.8.28 Jun 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants