-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #788 from hacspec/fix-296
Fix #296
- Loading branch information
Showing
19 changed files
with
225 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,8 @@ loop, | |
monadic_action, | ||
monadic_binding, | ||
quote, | ||
block] | ||
block, | ||
dyn] | ||
|
||
module Full = On | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
--- | ||
source: test-harness/src/harness.rs | ||
expression: snapshot | ||
info: | ||
kind: | ||
Translate: | ||
backend: fstar | ||
info: | ||
name: dyn | ||
manifest: dyn/Cargo.toml | ||
description: ~ | ||
spec: | ||
optional: false | ||
broken: false | ||
issue_id: ~ | ||
positive: true | ||
snapshot: | ||
stderr: false | ||
stdout: true | ||
include_flag: ~ | ||
backend_options: ~ | ||
--- | ||
exit = 0 | ||
|
||
[stdout] | ||
diagnostics = [] | ||
|
||
[stdout.files] | ||
"Dyn.fst" = ''' | ||
module Dyn | ||
#set-options "--fuel 0 --ifuel 1 --z3rlimit 15" | ||
open Core | ||
open FStar.Mul | ||
|
||
class t_Printable (v_Self: Type0) (v_S: Type0) = { | ||
f_stringify_pre:v_Self -> bool; | ||
f_stringify_post:v_Self -> v_S -> bool; | ||
f_stringify:x0: v_Self | ||
-> Prims.Pure v_S (f_stringify_pre x0) (fun result -> f_stringify_post x0 result) | ||
} | ||
|
||
[@@ FStar.Tactics.Typeclasses.tcinstance] | ||
let impl: t_Printable i32 Alloc.String.t_String = | ||
{ | ||
f_stringify_pre = (fun (self: i32) -> true); | ||
f_stringify_post = (fun (self: i32) (out: Alloc.String.t_String) -> true); | ||
f_stringify | ||
= | ||
fun (self: i32) -> Alloc.String.f_to_string #i32 #FStar.Tactics.Typeclasses.solve self | ||
} | ||
|
||
let print | ||
(a: | ||
Alloc.Boxed.t_Box (dyn 1 (fun z -> t_Printable z Alloc.String.t_String)) | ||
Alloc.Alloc.t_Global) | ||
: Prims.unit = | ||
let _:Prims.unit = | ||
Std.Io.Stdio.v__print (Core.Fmt.impl_2__new_v1 (sz 2) | ||
(sz 1) | ||
(let list = [""; "\n"] in | ||
FStar.Pervasives.assert_norm (Prims.eq2 (List.Tot.length list) 2); | ||
Rust_primitives.Hax.array_of_list 2 list) | ||
(let list = | ||
[ | ||
Core.Fmt.Rt.impl_1__new_display #Alloc.String.t_String | ||
(f_stringify #(dyn 1 (fun z -> t_Printable z Alloc.String.t_String)) | ||
#Alloc.String.t_String | ||
#FStar.Tactics.Typeclasses.solve | ||
a | ||
<: | ||
Alloc.String.t_String) | ||
<: | ||
Core.Fmt.Rt.t_Argument | ||
] | ||
in | ||
FStar.Pervasives.assert_norm (Prims.eq2 (List.Tot.length list) 1); | ||
Rust_primitives.Hax.array_of_list 1 list) | ||
<: | ||
Core.Fmt.t_Arguments) | ||
in | ||
let _:Prims.unit = () in | ||
() | ||
''' |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[package] | ||
name = "dyn" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
|
||
[package.metadata.hax-tests] | ||
into."fstar" = { broken = false, snapshot = "stdout", issue_id = "296" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#![allow(dead_code)] | ||
|
||
pub trait Printable<S> { | ||
fn stringify(&self) -> S; | ||
} | ||
|
||
impl Printable<String> for i32 { | ||
fn stringify(&self) -> String { | ||
self.to_string() | ||
} | ||
} | ||
|
||
pub fn print(a: Box<dyn Printable<String>>) { | ||
println!("{}", a.stringify()); | ||
} |