Skip to content

# bug: Leading zeros in input arguments silently accepted #9748

Description

@chamitro

Bug Report

Cairo version: 2.16.1 (scarb 2.16.1)

Current behavior:

Input arguments with leading zeros (e.g., 007, 00100) are silently accepted and parsed as their decimal value. While this produces correct results, it indicates the input parser accepts non-canonical number representations without warning.

Expected behavior:

Either:

  1. Accept with canonical parsing (current behavior is functionally correct)
  2. Warn: Warning: input '007' has leading zeros, interpreting as 7

Steps to reproduce:

#[executable]
fn main(a: felt252) -> felt252 {
    a + 1
}
scarb execute --arguments="007" --print-program-output
# Output: 8 (007 parsed as 7, 7+1=8, no warning)

scarb execute --arguments="00100" --print-program-output
# Output: 101 (00100 parsed as 100)

Related code:

#[executable]
fn main(a: felt252) -> felt252 {
    a + 1
}

Other information:

Input Circom Noir Cairo Leo
007 Accepts (7) Accepts (7) ❌ Accepts (7) Rejects
00100 Accepts (100) Accepts (100) ❌ Accepts (100) Rejects

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions