Skip to content

(feat) AST->HIR Code prep #53

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

Merged
merged 11 commits into from
Apr 3, 2025
Merged

(feat) AST->HIR Code prep #53

merged 11 commits into from
Apr 3, 2025

Conversation

AlSchlo
Copy link
Collaborator

@AlSchlo AlSchlo commented Apr 3, 2025

This PR solves a bunch of problems in the DSL/HIR to allow for the initial transformation from AST -> HIR. Notably:

  1. Adds $ and * type extensions in the parser & type system.

Type$ stands for Costed(Type) is covariant and inherits Stored(Type)
Type* stands for Stored(Type) is covariant and inherits Type.

  1. Adds an implementation of map in the HIR and the engine where the keys are allowed to be hashed and compared against each other.

  2. Adds # to distinguish between field accesses in structs, and member function calls (with .).

  3. Fixes the Call evaluate engine function to include indexing arrays, tuples, maps, and operators (including a group/goal expansion when field access is needed).

  4. Added the Never type for the Fail expression in the type system.

@codecov-commenter
Copy link

codecov-commenter commented Apr 3, 2025

Codecov Report

Attention: Patch coverage is 93.61167% with 127 lines in your changes missing coverage. Please review.

Project coverage is 75.3%. Comparing base (f7f9b9f) to head (e620ffb).

Files with missing lines Patch % Lines
optd-dsl/src/parser/expr.rs 61.2% 24 Missing ⚠️
optd-core/src/bridge/from_cir.rs 0.0% 22 Missing ⚠️
optd-core/src/bridge/into_cir.rs 0.0% 18 Missing ⚠️
optd-dsl/src/utils/tests.rs 42.8% 16 Missing ⚠️
optd-dsl/src/engine/eval/expr.rs 98.7% 13 Missing ⚠️
optd-dsl/src/analyzer/map.rs 96.6% 11 Missing ⚠️
optd-dsl/src/analyzer/type.rs 95.3% 6 Missing ⚠️
optd-dsl/src/engine/eval/binary.rs 92.1% 6 Missing ⚠️
optd-dsl/src/engine/eval/core.rs 90.0% 3 Missing ⚠️
optd-dsl/src/analyzer/hir.rs 60.0% 2 Missing ⚠️
... and 4 more
Additional details and impacted files
Files with missing lines Coverage Δ
optd-dsl/src/analyzer/semantic_checker/error.rs 66.6% <100.0%> (+66.6%) ⬆️
optd-dsl/src/analyzer/type_checker/error.rs 0.0% <ø> (ø)
optd-dsl/src/engine/eval/match.rs 99.3% <100.0%> (+<0.1%) ⬆️
optd-dsl/src/engine/eval/operator.rs 100.0% <100.0%> (ø)
optd-dsl/src/engine/eval/unary.rs 80.8% <100.0%> (ø)
optd-dsl/src/engine/mod.rs 56.5% <100.0%> (+0.6%) ⬆️
optd-dsl/src/lexer/error.rs 5.6% <100.0%> (ø)
optd-dsl/src/lexer/lex.rs 97.9% <100.0%> (+<0.1%) ⬆️
optd-dsl/src/parser/function.rs 93.8% <100.0%> (+<0.1%) ⬆️
optd-dsl/src/parser/module.rs 100.0% <ø> (ø)
... and 15 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AlSchlo AlSchlo marked this pull request as ready for review April 3, 2025 13:45
@AlSchlo AlSchlo requested review from connortsui20, yliang412 and SarveshOO7 and removed request for connortsui20 April 3, 2025 13:46
@AlSchlo AlSchlo force-pushed the alexis/ast-to-hir branch from 89e1d65 to fc5d8e2 Compare April 3, 2025 13:49
@AlSchlo AlSchlo changed the title Alexis/ast to hir (feat) AST->HIR Code prep Apr 3, 2025
Copy link
Member

@connortsui20 connortsui20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have time to look at this in depth, but in general nothing looks out of the ordinary. I do think that error handling methodology could be improved, and from my experience having that done well is super helpful when actually doing the compilation (where a lot of stuff can go wrong)

@AlSchlo AlSchlo merged commit ed35467 into main Apr 3, 2025
11 checks passed
@AlSchlo AlSchlo deleted the alexis/ast-to-hir branch April 3, 2025 23:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants