-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Description
NamlType::Decimal { precision, scale } exists in the AST (ast/types.rs:43) and the typechecker maps it to Type::Float (infer.rs:1778, mod.rs:831), but the parser has no branch to parse decimal(p,s) syntax. The lexer also lacks a Keyword::Decimal variant.
As a result, decimal is lexed as an identifier and falls through to parse_named_or_generic_type, causing a type mismatch error.
Steps to Reproduce
fn main() {
var xx: decimal = 1.0;
}
Expected: Parses decimal as a type (or decimal(10,2) with precision/scale)
Actual: type mismatch: expected float, found Spur(3)
What exists
- AST:
NamlType::Decimal { precision: u8, scale: u8 }innamlc/src/ast/types.rs:43 - Typechecker:
NamlType::Decimal { .. } => Type::Floatininfer.rs:1778andmod.rs:831
What's missing
- Lexer: No
Keyword::Decimalvariant —decimalis lexed as an identifier - Parser: No branch in
parse_type()(parser/types.rs:21-46) to handledecimalordecimal(p,s)
Fix
- Add
Decimalto theKeywordenum in the lexer - Add a parsing branch in
parse_type()forKeyword::Decimal - Parse optional
(precision, scale)params — e.g.decimaldefaults todecimal(10,2),decimal(18,6)sets explicit precision/scale
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels