-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously kinds needed to be annotated on type synonyms, i.e. ``` type option_syn('a : Type) -> Type = option('a) ``` and on type constructors ``` struct S('a : Int, 'b : Type) = ... ``` This commit adds a kind-inference algorithm, so that these can become ``` type option_syn('a) = option('a) struct S('a, 'b) = ... ```
- Loading branch information
Showing
20 changed files
with
1,080 additions
and
325 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
Large diffs are not rendered by default.
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
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 |
---|---|---|
@@ -1,15 +1,5 @@ | ||
[93mType error[0m: | ||
[96mfail/synonym_rec.sail[0m:2.0-10: | ||
[96mfail/synonym_rec.sail[0m:2.9-10: | ||
2[96m |[0mtype T = T | ||
[91m |[0m[91m^--------^[0m | ||
[91m |[0m Types are not well-formed within this type definition. Note that recursive types are forbidden. | ||
[91m |[0m | ||
[91m |[0m [93mCaused by [0m[96mfail/synonym_rec.sail[0m:2.9-10: | ||
[91m |[0m 2[96m |[0mtype T = T | ||
[91m |[0m [91m |[0m [91m^[0m | ||
[91m |[0m [91m |[0m Well-formedness check failed for type | ||
[91m |[0m [91m |[0m | ||
[91m |[0m [91m |[0m [93mCaused by [0m[96mfail/synonym_rec.sail[0m:2.9-10: | ||
[91m |[0m [91m |[0m 2[96m |[0mtype T = T | ||
[91m |[0m [91m |[0m [91m |[0m [91m^[0m | ||
[91m |[0m [91m |[0m [91m |[0m Undefined type T | ||
[91m |[0m [91m^[0m | ||
[91m |[0m Failed to infer kind for this type |
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 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val f : forall 'b. bool('b) -> unit | ||
|
||
val g : forall 'a. 'a -> 'a | ||
|
||
val h : forall 'n 'a. vector('n, 'a) -> unit |
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,16 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val f : forall 'b. int('b) -> unit | ||
|
||
function f(b) = { | ||
let 'a = 3; | ||
if b == 3 then { | ||
let _ : bool('a == 'b) = true; | ||
} | ||
} | ||
|
||
function g forall 'b. (b: bool('b)) -> unit = { | ||
() | ||
} |
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,8 @@ | ||
[93mType error[0m: | ||
[96mpass/fn_kind_infer_body/v1.sail[0m:14.18-28: | ||
14[96m |[0mfunction g forall ('b : Int). (b: bool('b)) -> unit = { | ||
[92m |[0m [92m^--------^[0m [92mInferred kind Int from this[0m | ||
[96mpass/fn_kind_infer_body/v1.sail[0m:14.39-41: | ||
14[96m |[0mfunction g forall ('b : Int). (b: bool('b)) -> unit = { | ||
[91m |[0m [91m^^[0m | ||
[91m |[0m Expected this type to have kind Int but found kind Bool |
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,16 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val f : forall 'b. int('b) -> unit | ||
|
||
function f(b) = { | ||
let 'a = 3; | ||
if b == 3 then { | ||
let _ : bool('a == 'b) = true; | ||
} | ||
} | ||
|
||
function g forall ('b : Int). (b: bool('b)) -> unit = { | ||
() | ||
} |
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,8 @@ | ||
[93mType error[0m: | ||
[96mpass/fn_kind_infer_body/v2.sail[0m:14.15-17: | ||
14[96m |[0mval g : forall 'b. bool('b) -> unit | ||
[92m |[0m [92m^^[0m [92m'b defined with kind Bool here[0m | ||
[96mpass/fn_kind_infer_body/v2.sail[0m:16.18-28: | ||
16[96m |[0mfunction g forall ('b : Int). (b: int('b)) -> unit = { | ||
[91m |[0m [91m^--------^[0m | ||
[91m |[0m 'b defined here with kind Int in the function body, which is inconsistent with the function header |
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,18 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val f : forall 'b. int('b) -> unit | ||
|
||
function f(b) = { | ||
let 'a = 3; | ||
if b == 3 then { | ||
let _ : bool('a == 'b) = true; | ||
} | ||
} | ||
|
||
val g : forall 'b. bool('b) -> unit | ||
|
||
function g forall ('b : Int). (b: int('b)) -> unit = { | ||
() | ||
} |
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,8 @@ | ||
[93mType error[0m: | ||
[96mpass/fn_kind_infer_body/v3.sail[0m:14.4-5: | ||
14[96m |[0mval g : forall 'b. bool('b) -> unit | ||
[92m |[0m [92m^[0m [92mdeclared here[0m | ||
[96mpass/fn_kind_infer_body/v3.sail[0m:16.11-43: | ||
16[96m |[0mfunction g forall 'b. (b: bool('b)) -> unit = { | ||
[91m |[0m [91m^------------------------------^[0m | ||
[91m |[0m Duplicate quantifier between inline annotation and 'val' declaration |
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,18 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
val f : forall 'b. int('b) -> unit | ||
|
||
function f(b) = { | ||
let 'a = 3; | ||
if b == 3 then { | ||
let _ : bool('a == 'b) = true; | ||
} | ||
} | ||
|
||
val g : forall 'b. bool('b) -> unit | ||
|
||
function g forall 'b. (b: bool('b)) -> unit = { | ||
() | ||
} |
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,8 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
struct S('a, 'n) = { | ||
field1 : 'a, | ||
field2 : bitvector('n), | ||
} |
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,5 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
type xlen = 32 |
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,14 @@ | ||
default Order dec | ||
|
||
$include <prelude.sail> | ||
|
||
union my_option('a) = { | ||
My_none : unit, | ||
Ny_some : 'a, | ||
} | ||
|
||
union test_union('a, 'b, 'c) = { | ||
A : list('a), | ||
B : bool('b), | ||
C : int('c), | ||
} |
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 |
---|---|---|
@@ -1,10 +1,5 @@ | ||
[93mType error[0m: | ||
[96mpass/wf_register_type/v1.sail[0m:7.13-24: | ||
[96mpass/wf_register_type/v1.sail[0m:7.18-23: | ||
7[96m |[0mregister r : bits(x / 2) = 0x0 | ||
[91m |[0m [91m^---------^[0m | ||
[91m |[0m Well-formedness check failed for type | ||
[91m |[0m | ||
[91m |[0m [93mCaused by [0m[96mpass/wf_register_type/v1.sail[0m:7.18-23: | ||
[91m |[0m 7[96m |[0mregister r : bits(x / 2) = 0x0 | ||
[91m |[0m [91m |[0m [91m^---^[0m | ||
[91m |[0m [91m |[0m Unknown type level operator or function (operator /) | ||
[91m |[0m [91m^---^[0m | ||
[91m |[0m Unknown type level operator or function (operator /) |