-
-
Notifications
You must be signed in to change notification settings - Fork 2
Type inference #495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type inference #495
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This is a major refactoring pull request that restructures the codebase's module organization and introduces visitor patterns for AST traversal. The changes reorganize code from a monolithic precompiler.rs into separate, focused modules.
Key Changes:
- Splits precompiler functionality into separate modules (
precompiler/mod.rs,scope.rs,scope_stack.rs,precompiled_ast.rs) - Introduces visitor pattern for expressions and type expressions with new
visitormodule - Adds type inference system with detailed error handling
- Introduces formatter module for code formatting with configurable options
- Updates import paths throughout codebase to reflect new structure
Reviewed Changes
Copilot reviewed 70 out of 72 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/visitor/type_expression/visitable.rs |
Implements visitor pattern for type expressions with walk_children methods |
src/visitor/type_expression/mod.rs |
Defines TypeExpressionVisitor trait with visit methods for each type variant |
src/visitor/expression/visitable.rs |
Implements visitor pattern for expressions with walk_children methods |
src/visitor/expression/mod.rs |
Defines ExpressionVisitor trait extending TypeExpressionVisitor |
src/visitor/mod.rs |
Defines VisitAction enum and includes tests for visitor implementation |
src/type_inference/mod.rs |
Implements type inference using visitor pattern |
src/type_inference/error.rs |
Defines error types for type inference |
src/type_inference/options.rs |
Configuration options for type inference |
src/precompiler/mod.rs |
Main precompiler logic refactored from old compiler/precompiler.rs |
src/precompiler/precompiled_ast.rs |
AST metadata structures |
src/precompiler/scope_stack.rs |
Scope management during precompilation |
src/fmt/mod.rs |
Code formatter with pretty printing |
src/runtime/mod.rs |
Added debug print statement |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
| Branch | feat/type-inference |
| Testbed | ubuntu-latest |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result microseconds (µs) (Result Δ%) | Upper Boundary microseconds (µs) (Limit %) |
|---|---|---|---|
| dxb to json/test1.json | 📈 view plot 🚷 view threshold | 61.29 µs(-3.77%)Baseline: 63.69 µs | 67.60 µs (90.66%) |
| dxb to json/test2.json | 📈 view plot 🚷 view threshold | 13,307.00 µs(+0.07%)Baseline: 13,297.86 µs | 13,721.92 µs (96.98%) |
| dxb to json/test3.json | 📈 view plot 🚷 view threshold | 141,920.00 µs(-0.55%)Baseline: 142,700.00 µs | 147,771.66 µs (96.04%) |
| dxb to runtime value/test1.json | 📈 view plot 🚷 view threshold | 54.60 µs(+37.59%)Baseline: 39.68 µs | 59.00 µs (92.54%) |
| dxb to runtime value/test2.json | 📈 view plot 🚷 view threshold | 14,562.00 µs(+33.34%)Baseline: 10,920.86 µs | 15,769.22 µs (92.34%) |
| dxb to runtime value/test3.json | 📈 view plot 🚷 view threshold | 159,880.00 µs(+65.70%)Baseline: 96,490.43 µs | 177,986.36 µs (89.83%) |
| json to dxb/test1.json | 📈 view plot 🚷 view threshold | 8,285.50 µs(+378.00%)Baseline: 1,733.38 µs | 10,139.86 µs (81.71%) |
| json to dxb/test2.json | 📈 view plot 🚷 view threshold | 8,699,000.00 µs(+519.44%)Baseline: 1,404,337.14 µs | 10,763,317.27 µs (80.82%) |
| json to dxb/test3.json | 📈 view plot 🚷 view threshold | 49,843,000.00 µs(+468.88%)Baseline: 8,761,642.86 µs | 61,468,591.49 µs (81.09%) |
| json to runtime value datex auto static detection/test1.json | 📈 view plot 🚷 view threshold | 8,232.60 µs(+374.93%)Baseline: 1,733.42 µs | 10,071.82 µs (81.74%) |
| json to runtime value datex auto static detection/test2.json | 📈 view plot 🚷 view threshold | 8,757,000.00 µs(+517.69%)Baseline: 1,417,710.00 µs | 10,833,948.07 µs (80.83%) |
| json to runtime value datex auto static detection/test3.json | 📈 view plot 🚷 view threshold | 50,055,000.00 µs(+465.32%)Baseline: 8,854,271.43 µs | 61,714,396.64 µs (81.11%) |
| json to runtime value datex forced static/test1.json | 📈 view plot 🚷 view threshold | 8,005.90 µs(+372.33%)Baseline: 1,694.99 µs | 9,791.83 µs (81.76%) |
| json to runtime value datex forced static/test2.json | 📈 view plot 🚷 view threshold | 8,556,100.00 µs(+517.31%)Baseline: 1,386,032.86 µs | 10,585,159.52 µs (80.83%) |
| json to runtime value datex forced static/test3.json | 📈 view plot 🚷 view threshold | 48,987,000.00 µs(+465.74%)Baseline: 8,658,942.86 µs | 60,399,424.40 µs (81.11%) |
| json to runtime value datex/test1.json | 📈 view plot 🚷 view threshold | 8,170.20 µs(+372.56%)Baseline: 1,728.92 µs | 9,993.02 µs (81.76%) |
| json to runtime value datex/test2.json | 📈 view plot 🚷 view threshold | 8,720,800.00 µs(+516.00%)Baseline: 1,415,712.86 µs | 10,788,070.76 µs (80.84%) |
| json to runtime value datex/test3.json | 📈 view plot 🚷 view threshold | 50,005,000.00 µs(+463.97%)Baseline: 8,866,542.86 µs | 61,646,759.61 µs (81.12%) |
| json to runtime value json_syntax/test1.json | 📈 view plot 🚷 view threshold | 20.91 µs(+3.38%)Baseline: 20.23 µs | 21.49 µs (97.29%) |
| json to runtime value json_syntax/test2.json | 📈 view plot 🚷 view threshold | 6,531.70 µs(-0.34%)Baseline: 6,553.79 µs | 6,976.55 µs (93.62%) |
| json to runtime value json_syntax/test3.json | 📈 view plot 🚷 view threshold | 70,147.00 µs(-14.68%)Baseline: 82,216.43 µs | 97,865.35 µs (71.68%) |
| json to runtime value serde_json/test1.json | 📈 view plot 🚷 view threshold | 6.19 µs(-1.49%)Baseline: 6.28 µs | 6.54 µs (94.53%) |
| json to runtime value serde_json/test2.json | 📈 view plot 🚷 view threshold | 2,071.10 µs(-2.75%)Baseline: 2,129.59 µs | 2,214.41 µs (93.53%) |
| json to runtime value serde_json/test3.json | 📈 view plot 🚷 view threshold | 14,630.00 µs(-9.68%)Baseline: 16,197.14 µs | 18,744.71 µs (78.05%) |
| runtime init | 📈 view plot 🚷 view threshold | 32.14 µs(-76.78%)Baseline: 138.44 µs | 1,198.66 µs (2.68%) |
| runtime value to dxb/test1.json | 📈 view plot 🚷 view threshold | 6.19 µs(+66.80%)Baseline: 3.71 µs | 6.89 µs (89.81%) |
| runtime value to dxb/test2.json | 📈 view plot 🚷 view threshold | 1,669.10 µs(+70.40%)Baseline: 979.49 µs | 1,864.33 µs (89.53%) |
| runtime value to dxb/test3.json | 📈 view plot 🚷 view threshold | 18,672.00 µs(+84.56%)Baseline: 10,116.79 µs | 21,133.60 µs (88.35%) |
| runtime value to json datex/test1.json | 📈 view plot 🚷 view threshold | 67.22 µs(-1.35%)Baseline: 68.15 µs | 71.30 µs (94.28%) |
| runtime value to json datex/test2.json | 📈 view plot 🚷 view threshold | 14,763.00 µs(+2.78%)Baseline: 14,364.14 µs | 15,076.52 µs (97.92%) |
| runtime value to json datex/test3.json | 📈 view plot 🚷 view threshold | 159,750.00 µs(+3.25%)Baseline: 154,720.00 µs | 163,035.16 µs (97.98%) |
| runtime value to json json_syntax/test1.json | 📈 view plot 🚷 view threshold | 10.42 µs(-2.58%)Baseline: 10.70 µs | 11.16 µs (93.41%) |
| runtime value to json json_syntax/test2.json | 📈 view plot 🚷 view threshold | 4,362.50 µs(-3.66%)Baseline: 4,528.37 µs | 4,788.16 µs (91.11%) |
| runtime value to json json_syntax/test3.json | 📈 view plot 🚷 view threshold | 58,463.00 µs(-7.20%)Baseline: 62,995.86 µs | 71,745.59 µs (81.49%) |
| runtime value to json serde_json/test1.json | 📈 view plot 🚷 view threshold | 2.85 µs(-2.60%)Baseline: 2.93 µs | 3.31 µs (86.01%) |
| runtime value to json serde_json/test2.json | 📈 view plot 🚷 view threshold | 916.18 µs(-6.46%)Baseline: 979.43 µs | 1,163.54 µs (78.74%) |
| runtime value to json serde_json/test3.json | 📈 view plot 🚷 view threshold | 9,514.10 µs(-4.79%)Baseline: 9,992.43 µs | 12,176.41 µs (78.14%) |
e4a1f5b to
a517a8c
Compare
|
rebased to release/0.0.7, first merge #497 |
eae6b4a to
fd418c0
Compare
…ed implementation
…and refactoring expression inference
…h type annotations
…g types in statements
… inference functions
… VisitAction enum
103f67a to
4588006
Compare
This PR updates the type formatter to use the new visitor trait of #461
See https://github.com/unyt-org/datex-core/tree/feat/type-inference/src/type_inference