Skip to content

Commit

Permalink
feat: turn type aliases extraction off by default
Browse files Browse the repository at this point in the history
Fixes #708
  • Loading branch information
W95Psp committed Jun 10, 2024
1 parent 15856f7 commit b7ee6f1
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
10 changes: 10 additions & 0 deletions cli/options/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,16 @@ pub struct BackendOptions {
#[arg(short, long = "debug-engine")]
pub debug_engine: Option<DebugEngineMode>,

/// Extract type aliases. This is disabled by default, since
/// extracted terms depends on expanded types rather than on type
/// aliases. Turning this option on is discouraged: Rust type
/// synonyms can ommit generic bounds, which are ususally
/// necessary in the hax backends, leading to typechecking
/// errors. For more details see
/// https://github.com/hacspec/hax/issues/708.
#[arg(long)]
pub extract_type_aliases: bool,

#[command(flatten)]
pub translation_options: TranslationOptions,
}
Expand Down
7 changes: 7 additions & 0 deletions engine/bin/lib.ml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ let run (options : Types.engine_options) : Types.output =
options.backend.translation_options.include_namespaces
in
let items = import_thir_items include_clauses options.input in
let items =
if options.backend.extract_type_aliases then items
else
List.filter
~f:(function { v = TyAlias _; _ } -> false | _ -> true)
items
in
Logs.info (fun m ->
m "Applying phase for backend %s"
([%show: Diagnostics.Backend.t] M.backend));
Expand Down
6 changes: 0 additions & 6 deletions test-harness/src/snapshots/toolchain__traits into-fstar.snap
Original file line number Diff line number Diff line change
Expand Up @@ -181,12 +181,6 @@ open FStar.Mul

type t_StructWithGenericBounds (v_T: Type0) {| i1: Core.Clone.t_Clone v_T |} =
| StructWithGenericBounds : v_T -> t_StructWithGenericBounds v_T

unfold
let t_SynonymA (#v_T: Type0) = t_StructWithGenericBounds v_T

unfold
let t_SynonymB (#v_T: Type0) = t_StructWithGenericBounds (v_T & v_T)
'''
"Traits.Unconstrainted_types_issue_677_.fst" = '''
module Traits.Unconstrainted_types_issue_677_
Expand Down

0 comments on commit b7ee6f1

Please sign in to comment.