#20322·aptos-core

[Bug] TypeTag::I8…I256 render to strings that move_core_types::parser cannot parse

Author: Nuhiat-ArefinCreated Aug 5, 2026Updated Sep 20, 2026
LabelsbugStale

Summary

move_core_types::parser cannot parse the canonical text representations of signed-integer TypeTag variants:

i8
i16
i32
i64
i128
i256

TypeTag::to_canonical_string() and TypeTag::to_short_string() emit these strings, but the parser has no corresponding signed-integer tokens or parse_type_tag match arms.

A signed-integer type tag therefore cannot round-trip through its own canonical representation:

TypeTag::I64
  --to_canonical_string()--> "i64"
  --parse_type_tag()-------> Err

Because MoveType::from_str delegates to this parser, the problem reaches the JSON REST API. Signed integers cannot be used as generic type arguments for entry functions, scripts, or views, and resource types containing signed-integer arguments cannot be parsed from their rendered type strings.

For example:

vector<i64>
0x1::m::S<i64>
0x1::table::Table<i64,u64>

are rejected, while the corresponding u64 forms are accepted.

The BCS signed-transaction path is unaffected because type tags are encoded directly and do not pass through text parsing. This is a JSON/API-layer correctness issue, not a VM or consensus issue.

To reproduce

Code snippet to reproduce

rust
use move_core_types::language_storage::TypeTag;
use move_core_types::parser::parse_type_tag;

fn main() {
    for tag in [
        TypeTag::I8,
        TypeTag::I16,
        TypeTag::I32,
        TypeTag::I64,
        TypeTag::I128,
        TypeTag::I256,
    ] {
        let rendered = tag.to_canonical_string();

        println!("{tag:?} renders as {rendered:?}");
        println!("parse result: {:?}", parse_type_tag(&rendered));

        assert!(
            parse_type_tag(&rendered).is_ok(),
            "{tag:?} did not round-trip through {rendered:?}"
        );
    }
}

Nested and generic forms also fail:

rust
use move_core_types::parser::parse_type_tag;

fn main() {
    for value in [
        "vector<i64>",
        "0x1::m::S<i64>",
    ] {
        println!("{value}: {:?}", parse_type_tag(value));
        assert!(parse_type_tag(value).is_ok());
    }
}

The same behavior is visible through the API request types.

For example, a view request containing:

json
{
  "function": "0x1::m::f",
  "type_arguments": ["i64"],
  "arguments": []
}

deserializes the type argument as an unparsable MoveType, then fails when it is converted to TypeTag.

Stack trace/error message

TypeTag::I64.to_canonical_string() = "i64"

parse_type_tag("i64")
  -> Err: unexpected token Name("i64"), expected type tag

Nested and generic positions:

parse_type_tag("vector<i64>")
  -> Err: unexpected token Name("i64"), expected type tag

parse_type_tag("0x1::m::S<i64>")
  -> Err: unexpected token Name("i64"), expected type tag

API request-type behavior:

MoveType::from_str("i64")
  -> Ok(Unparsable("i64"))

TypeTag::try_from(...)
  -> Err(
       Invalid move type for converting into `TypeTag`:
       Unparsable("i64")
     )

Resource type parsing:

0x1::table::Table<i64,u64>
  -> REJECTED:
     invalid struct tag,
     unexpected token Name("i64"),
     expected type tag

0x1::table::Table<u64,u64>
  -> accepted

Unsigned control:

MoveType::from_str("u64")
  -> valid MoveType

TypeTag::try_from(...)
  -> TypeTag::U64

Expected Behavior

Every TypeTag produced by the canonical renderer should be accepted by the corresponding parser.

The following should hold for all signed-integer variants:

rust
let rendered = tag.to_canonical_string();
let parsed = parse_type_tag(&rendered)?;

assert_eq!(parsed, tag);

The parser should recognize:

i8   -> TypeTag::I8
i16  -> TypeTag::I16
i32  -> TypeTag::I32
i64  -> TypeTag::I64
i128 -> TypeTag::I128
i256 -> TypeTag::I256

Signed integers should also work in nested and generic positions, including:

vector<i64>
0x1::m::S<i64>
0x1::table::Table<i64,u64>

JSON REST API requests should accept signed integers as type arguments for entry functions, scripts, and views.

MoveType::from_str("i64") should produce the signed-integer MoveType variant rather than MoveType::Unparsable("i64").

Additional context

The renderer/parser asymmetry is in these locations:

Renderer

third_party/move/move-core/types/src/language_storage.rs

  • The signed variants are defined with Serde names i8 through i256.
  • to_canonical_string() emits i8 through i256.
  • to_short_string() emits the same strings.

Parser

third_party/move/move-core/types/src/parser.rs

  • Token has no signed-integer type variants.
  • name_token recognizes u8, u16, u32, u64, u128, and u256, but not their signed equivalents.
  • Parser::parse_type_tag has no signed-integer match arms.

As a result, i64 is tokenized as:

Token::Name("i64")

and rejected where a type tag is expected.

All public parsing entry points use the same token table, including:

parse_type_tag
parse_type_tags
parse_struct_tag
parse_transaction_argument

The newer parser in:

third_party/move/move-command-line-common/src/parser.rs

already maps i8 through i256 to the corresponding signed ParsedType and TypeTag variants. The omission appears specific to the legacy move_core_types::parser, which is used by the API types.

The API impact originates in:

api/types/src/move_types.rs

MoveType::from_str delegates to parse_type_tag. When parsing fails, it produces MoveType::Unparsable rather than returning an error immediately. Later conversion to TypeTag rejects that value.

Affected JSON-facing surfaces include:

  • EntryFunctionPayload.type_arguments
  • ScriptPayload.type_arguments
  • ViewRequest.type_arguments
  • MoveStructTag::from_str

Module ABI responses can render "i64" correctly, but a Rust client using aptos-api-types can deserialize that output as:

MoveType::Unparsable("i64")

The error then surfaces later during conversion instead of at deserialization.

This does not appear to be a dormant feature:

  • Signed integers were added in bytecode format v9.
  • The default bytecode version is v9.
  • Signed integers are part of stable language version 2.3.
  • The VM materializes signed-integer type tags.
  • Compiler tests use signed integers in generic positions, including vector<i64> and S3<i64>.
  • Binary format v9 is enabled on mainnet.

This appears related to the incomplete peripheral rollout described in #17645, which notes that REST API types had not yet been addressed.

#17758 added the canonical rendering and API MoveType support for signed integers but did not update move_core_types::parser, which appears to have introduced this asymmetry.

Suggested fix

Mirror the existing unsigned-integer implementation by adding:

  • Six signed-integer Token variants.
  • Six entries in name_token.
  • Six signed-integer arms in parse_type_tag.