Skip to content

Fix parser panic for radix literals in default parameters #475

Closed

Description

@LunaStev

Problem

The frontend panics while parsing a non-decimal integer literal used as a default parameter value.

fun value(number: i32 = 0x10) -> i32 { return number; }
fun main() -> i32 { return value(); }

On current master plus PR #474, wavec check exits with status 101:

front/parser/src/parser/functions.rs:154:52
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }

parse_default_value currently feeds the token spelling to decimal-only str::parse().unwrap(). User source must never reach a parser panic, and default values should follow the same literal contract as ordinary expressions and constants.

This is an alpha release blocker found during the audit following #474.

Scope

  • Remove the integer and float unwrap paths from default-value parsing.
  • Reuse the frontend's canonical numeric-literal parser instead of creating a second grammar.
  • Accept every numeric literal spelling that is valid in an ordinary constant expression.
  • Return a structured source diagnostic for malformed or out-of-range defaults.
  • Add decimal, binary, hexadecimal, malformed, and overflow regression cases.

Acceptance criteria

  • The reproducer checks successfully and evaluates the default as 16.
  • Malformed default literals produce a nonzero compiler result without a Rust panic.
  • Numeric default parameters and ordinary numeric expressions use one documented grammar.

Related: #405, #474

Activity

  1. added
    bug
    good first issue
    needs testing
    on Sep 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issueneeds testing

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions