Skip to content
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

Check mapping completeness #647

Open
wants to merge 1 commit into
base: sail2
Choose a base branch
from

Conversation

trdthg
Copy link
Contributor

@trdthg trdthg commented Jul 26, 2024

fix #424

Add basic mapdef completeness check

  • converting mpat to pat, then to gpat, and reusing the match checking logic

@trdthg trdthg marked this pull request as draft July 26, 2024 12:43
Copy link

github-actions bot commented Jul 26, 2024

Test Results

    9 files  ±0     21 suites  ±0   0s ⏱️ ±0s
  664 tests +1    664 ✅ +1  0 💤 ±0  0 ❌ ±0 
2 114 runs  +2  2 113 ✅ +2  1 💤 ±0  0 ❌ ±0 

Results for commit bd229e9. ± Comparison against base commit 48e0ca1.

♻️ This comment has been updated with latest results.

@trdthg trdthg force-pushed the mapping-match-complete branch 3 times, most recently from 78a0c43 to 5fb2a22 Compare July 27, 2024 12:27
Comment on lines 80 to 85
let ast, env = Type_error.check env ast in
let ast = Scattered.descatter ast in
let ast, env = Type_error.check Type_check.initial_env (Type_check.strip_ast ast) in
let side_effects = Effects.infer_side_effects asserts_termination ast in
Effects.check_side_effects side_effects ast;
let () = if !opt_ddump_tc_ast then Pretty_print_sail.output_ast stdout (Type_check.strip_ast ast) else () in
Copy link
Contributor Author

Choose a reason for hiding this comment

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

type_check again to add_attrs after scattered mapdefs get together

Comment on lines +1049 to +1064
(* TODO: handle unsupported syntax *)
try
(* prepare left *)
let lpats = List.map (fun mapcl -> lpat_of_mapcl mapcl true) mapcls in
let _, lpats = opt_cases_to_pats 0 have_guard lpats in
let lmatrix =
Rows (List.mapi (fun i (l, pat) -> ({ loc = l; num = i }, Columns [generalize ctx (Some typl) pat])) lpats)
in
(* prepare right *)
let rpats = List.map (fun mapcl -> lpat_of_mapcl mapcl false) mapcls in
let _, rpats = opt_cases_to_pats 0 have_guard rpats in
let rmatrix =
Rows (List.mapi (fun i (l, pat) -> ({ loc = l; num = i }, Columns [generalize ctx (Some typr) pat])) rpats)
in
is_complete_matrixs ~keyword:"mapping" l ctx have_guard [(typl, lmatrix); (typr, rmatrix)]
with _ -> false
Copy link
Contributor Author

@trdthg trdthg Jul 29, 2024

Choose a reason for hiding this comment

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

Some syntaxes are not supported in match, but are allowed by mapping

example: test/c/poly_mapping2.sail

mapping test2m : bits(3) <-> bits(5) = { v <-> zero_int_bits(2) : bits(2) @ v }

When encountering this kind of syntax, an exception will be thrown, so here fallback to false.

@trdthg trdthg marked this pull request as ready for review July 29, 2024 09:41
@trdthg trdthg force-pushed the mapping-match-complete branch from 2f18442 to bd229e9 Compare July 29, 2024 11:50
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.

Found side effects: incomplete pattern match; but it is complete?
1 participant