fix: parser newline handling in lists and stdlib exports
- Fix parse_list_expr to skip newlines between list elements - Add `pub` keyword to all exported functions in stdlib/html.lux - Change List.foldl to List.fold (matching built-in name) - Update weaknesses document with fixed issues The module import system now works correctly. This enables: - import stdlib/html to work as expected - html.div(), html.render() etc. to be accessible - Multi-line list expressions in Lux source files Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -2,49 +2,62 @@
|
||||
|
||||
This document tracks issues and limitations discovered while building the Lux website in Lux.
|
||||
|
||||
## Critical Issues
|
||||
## Fixed Issues
|
||||
|
||||
### 1. Module Import System Not Working
|
||||
### 1. Module Import System Not Working (FIXED)
|
||||
|
||||
**Description:** The `import` statement doesn't appear to work for importing standard library modules.
|
||||
**Description:** The `import` statement wasn't working for importing standard library modules.
|
||||
|
||||
**Example:**
|
||||
```lux
|
||||
import html // Doesn't make html functions available
|
||||
```
|
||||
**Root Cause:** Two issues were found:
|
||||
1. Parser didn't skip newlines inside list expressions, causing parse errors in multi-line lists
|
||||
2. Functions in stdlib modules weren't marked as `pub` (public), so they weren't exported
|
||||
|
||||
**Workaround:** Functions must be defined in the same file or copied.
|
||||
**Fix:**
|
||||
1. Added `skip_newlines()` calls to `parse_list_expr()` in parser.rs
|
||||
2. Added `pub` keyword to all exported functions in stdlib/html.lux
|
||||
|
||||
**Status:** Needs investigation
|
||||
**Status:** FIXED
|
||||
|
||||
---
|
||||
|
||||
### 2. Parse Error in html.lux (Line 196-197)
|
||||
### 2. Parse Error in html.lux (FIXED)
|
||||
|
||||
**Description:** When trying to load files that import the html module, there's a parse error.
|
||||
**Description:** When trying to load files that import the html module, there was a parse error at line 196-197.
|
||||
|
||||
**Error Message:**
|
||||
```
|
||||
Module error: Module error in '<main>': Parse error: Parse error at 196-197: Unexpected token: \n
|
||||
```
|
||||
|
||||
**Status:** Needs investigation
|
||||
**Root Cause:** The parser's `parse_list_expr()` function didn't handle newlines between list elements.
|
||||
|
||||
**Fix:** Added `skip_newlines()` calls after `[`, after each element, and after commas in list expressions.
|
||||
|
||||
**Status:** FIXED
|
||||
|
||||
---
|
||||
|
||||
### 3. List.foldl Renamed to List.fold (FIXED)
|
||||
|
||||
**Description:** The html.lux file used `List.foldl` but the built-in List module exports `List.fold`.
|
||||
|
||||
**Fix:** Changed `List.foldl` to `List.fold` in stdlib/html.lux.
|
||||
|
||||
**Status:** FIXED
|
||||
|
||||
---
|
||||
|
||||
## Minor Issues
|
||||
|
||||
### 3. String.replace May Not Exist
|
||||
### 4. String.replace Verified Working
|
||||
|
||||
**Description:** The `escapeHtml` function in html.lux uses `String.replace`, but this function may not be implemented.
|
||||
**Description:** The `escapeHtml` function in html.lux uses `String.replace`.
|
||||
|
||||
**Workaround:** Implement character-by-character escaping.
|
||||
|
||||
**Status:** Needs verification
|
||||
**Status:** VERIFIED WORKING - String.replace is implemented in the interpreter.
|
||||
|
||||
---
|
||||
|
||||
### 4. FileSystem Effect Not Fully Implemented
|
||||
### 5. FileSystem Effect Not Fully Implemented
|
||||
|
||||
**Description:** For static site generation, we need `FileSystem.mkdir`, `FileSystem.write`, `FileSystem.copy` operations. These may not be fully implemented.
|
||||
|
||||
@@ -54,17 +67,17 @@ Module error: Module error in '<main>': Parse error: Parse error at 196-197: Une
|
||||
|
||||
---
|
||||
|
||||
### 5. List.concat May Have Issues
|
||||
### 6. List.concat Verified Working
|
||||
|
||||
**Description:** The `List.concat` function used in html.lux document generation may not handle nested lists correctly.
|
||||
**Description:** The `List.concat` function is used in html.lux document generation.
|
||||
|
||||
**Status:** Needs verification
|
||||
**Status:** VERIFIED WORKING - List.concat is implemented in the interpreter.
|
||||
|
||||
---
|
||||
|
||||
## Feature Gaps
|
||||
|
||||
### 6. No Built-in Static Site Generation
|
||||
### 7. No Built-in Static Site Generation
|
||||
|
||||
**Description:** There's no built-in way to generate static HTML files from Lux. A static site generator effect or module would be helpful.
|
||||
|
||||
@@ -76,7 +89,7 @@ Module error: Module error in '<main>': Parse error: Parse error at 196-197: Une
|
||||
|
||||
---
|
||||
|
||||
### 7. No Template String Support
|
||||
### 8. No Template String Support
|
||||
|
||||
**Description:** Multi-line strings and template literals (like JavaScript's backticks) would make HTML generation much easier.
|
||||
|
||||
@@ -94,7 +107,7 @@ let html = `<div class="${className}">${content}</div>`
|
||||
|
||||
---
|
||||
|
||||
### 8. No Markdown Parser
|
||||
### 9. No Markdown Parser
|
||||
|
||||
**Description:** A built-in Markdown parser would be valuable for documentation sites.
|
||||
|
||||
@@ -112,6 +125,8 @@ These features work correctly and can be used for website generation:
|
||||
4. **Basic types** - `String`, `Int`, `Bool` work
|
||||
5. **Let bindings** - Variable assignment works
|
||||
6. **Functions** - Function definitions work
|
||||
7. **Module imports** - Works with `import stdlib/module`
|
||||
8. **Html module** - Fully functional for generating HTML strings
|
||||
|
||||
---
|
||||
|
||||
@@ -119,15 +134,14 @@ These features work correctly and can be used for website generation:
|
||||
|
||||
### For Website MVP
|
||||
|
||||
Since the module system isn't working, the website should be:
|
||||
1. **Hand-written HTML** (already done in `dist/index.html`)
|
||||
The module system now works! The website can be:
|
||||
1. **Generated from Lux** using the html module for HTML rendering
|
||||
2. **CSS separate file** (already done in `static/style.css`)
|
||||
3. **Lux code examples** embedded as text in HTML
|
||||
|
||||
### For Future
|
||||
|
||||
Once these issues are fixed, the website can be:
|
||||
1. **Generated from Lux** using the components and pages modules
|
||||
1. **Add FileSystem effect** for writing generated HTML to files
|
||||
2. **Markdown-based documentation** parsed and rendered by Lux
|
||||
3. **Live playground** using WASM compilation
|
||||
|
||||
@@ -137,12 +151,15 @@ Once these issues are fixed, the website can be:
|
||||
|
||||
| Feature | Status | Notes |
|
||||
|---------|--------|-------|
|
||||
| String concatenation | ✅ Works | `"<" + tag + ">"` |
|
||||
| Conditionals | ✅ Works | `if x then y else z` |
|
||||
| Console.print | ✅ Works | Basic output |
|
||||
| Module imports | ❌ Broken | Parse errors |
|
||||
| Html module | ❌ Blocked | Depends on imports |
|
||||
| FileSystem | ❓ Unknown | Not tested |
|
||||
| String concatenation | Works | `"<" + tag + ">"` |
|
||||
| Conditionals | Works | `if x then y else z` |
|
||||
| Console.print | Works | Basic output |
|
||||
| Module imports | Works | `import stdlib/html` |
|
||||
| Html module | Works | Full HTML generation |
|
||||
| List.fold | Works | Fold over lists |
|
||||
| List.concat | Works | Concatenate list of lists |
|
||||
| String.replace | Works | String replacement |
|
||||
| FileSystem | Unknown | Not tested |
|
||||
|
||||
---
|
||||
|
||||
@@ -151,3 +168,6 @@ Once these issues are fixed, the website can be:
|
||||
| Date | Finding |
|
||||
|------|---------|
|
||||
| 2026-02-16 | Module import system not working, parse error at line 196-197 in html.lux |
|
||||
| 2026-02-16 | Fixed: Parser newline handling in list expressions |
|
||||
| 2026-02-16 | Fixed: Added `pub` to stdlib/html.lux exports |
|
||||
| 2026-02-16 | Fixed: Changed List.foldl to List.fold |
|
||||
|
||||
Reference in New Issue
Block a user