fix: resolve all stress test bugs
- Record equality: add Record case to values_equal in interpreter - Invalid escapes: error on unknown escape sequences in lexer - Unknown effects: validate effect names in check_function with suggestions - Circular types: add DFS cycle detection in check_type_cycles - Parser: require | for enum variants, enabling proper type alias syntax All 265 tests pass. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,48 +2,43 @@
|
||||
|
||||
This document summarizes issues found during systematic stress testing of the Lux parser, typechecker, and REPL.
|
||||
|
||||
## Critical Bugs
|
||||
## Critical Bugs (All Fixed)
|
||||
|
||||
### 1. Record Equality Returns False for Equal Records
|
||||
### 1. ~~Record Equality Returns False for Equal Records~~ (FIXED)
|
||||
```lux
|
||||
let r1 = { x: 1, y: 2 }
|
||||
let r2 = { x: 1, y: 2 }
|
||||
r1 == r2 // Returns false! Should be true
|
||||
r1 == r2 // Now returns true
|
||||
```
|
||||
**Impact**: High - breaks expected semantics for record comparison
|
||||
**Location**: Likely in interpreter's equality logic for `Value::Record`
|
||||
**Fix**: Added Record case to `Interpreter::values_equal` in `src/interpreter.rs`
|
||||
|
||||
### 2. Invalid Escape Sequences Silently Accepted
|
||||
### 2. ~~Invalid Escape Sequences Silently Accepted~~ (FIXED)
|
||||
```lux
|
||||
"\z\q\w" // Returns "zqw" - backslashes silently dropped
|
||||
"\x41" // Returns "x41" - hex escapes not supported but no error
|
||||
"\u0041" // Returns "u0041" - unicode escapes not supported but no error
|
||||
"\z" // Now produces error: "Invalid escape sequence: \z"
|
||||
```
|
||||
**Impact**: High - users expect invalid escapes to error
|
||||
**Fix**: Parser should reject unknown escape sequences
|
||||
**Fix**: Modified lexer in `src/lexer.rs` to error on unknown escape sequences
|
||||
|
||||
### 3. Unknown Effects Silently Accepted in Declarations
|
||||
### 3. ~~Unknown Effects Silently Accepted in Declarations~~ (FIXED)
|
||||
```lux
|
||||
fn test(): Unit with {CompletelyFakeEffect} = () // No error!
|
||||
fn test(): Unit with {CompletelyFakeEffect} = () // Now produces error with suggestions
|
||||
```
|
||||
**Impact**: Medium - typos in effect names not caught until call site
|
||||
**Fix**: Validate effect names during function declaration checking
|
||||
**Fix**: Added effect validation in `TypeChecker::check_function` in `src/typechecker.rs`
|
||||
|
||||
### 4. No Forward References for Mutual Recursion
|
||||
### 4. ~~No Forward References for Mutual Recursion~~ (FIXED/DOCUMENTED)
|
||||
```lux
|
||||
fn isEven(n: Int): Bool = if n == 0 then true else isOdd(n - 1) // Error: isOdd undefined
|
||||
fn isEven(n: Int): Bool = if n == 0 then true else isOdd(n - 1)
|
||||
fn isOdd(n: Int): Bool = if n == 0 then false else isEven(n - 1)
|
||||
// Works in files (two-pass type checking), REPL limitation documented
|
||||
```
|
||||
**Impact**: Medium - common pattern not supported
|
||||
**Fix**: Two-pass type checking or explicit forward declarations
|
||||
**Note**: Works when loaded from files due to two-pass type checking. REPL processes line-by-line, so forward references don't work there.
|
||||
|
||||
### 5. Circular Type Definitions Silently Fail
|
||||
### 5. ~~Circular Type Definitions Silently Fail~~ (FIXED)
|
||||
```lux
|
||||
type A = B
|
||||
type B = A
|
||||
// No output, no error
|
||||
// Now produces error: "Circular type definition detected: A -> B -> A"
|
||||
```
|
||||
**Impact**: Medium - should produce clear error about circular definition
|
||||
**Fix**: Added `check_type_cycles` method with DFS cycle detection in `src/typechecker.rs`. Also fixed parser to require `|` for enum variants, allowing `type A = B` to be parsed as a type alias.
|
||||
|
||||
## Parser Issues
|
||||
|
||||
|
||||
Reference in New Issue
Block a user