Skip to content

Commit

Permalink
feat(type_inference): added NumericDefaultInt cons
Browse files Browse the repository at this point in the history
 - Added NumericDefaultInt constraint
 - Updated IntegerLit semantic node to have monotype value
 - Updated semantic analysis to convert all NumericDefaultInt to int in final pass
  • Loading branch information
Akhil Jakatdar committed Oct 22, 2020
1 parent 4ea803e commit bbfcaa4
Show file tree
Hide file tree
Showing 20 changed files with 1,534 additions and 632 deletions.
643 changes: 415 additions & 228 deletions ast/internal/fbast/ast_generated.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions docs/SPEC.md
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,11 @@ Int, Uint, and Float types are Divisible.

Int, Uint, and Float types are Numeric.

##### Numeric Default Int Constraint

Integer literals are polymorphic and can be interpreted as Int, Uint, or Float types.
This constraint is used to infer the type of integer literals based on the context of the program.

##### Comparable Constraint

Comparable types are those the binary comparison operators `<`, `<=`, `>`, or `>=` accept.
Expand Down
2 changes: 2 additions & 0 deletions internal/fbsemantic/semantic.fbs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ enum Kind : ubyte {
Record,
Negatable,
Timeable,
NumericDefaultInt,
}

table Constraint {
Expand Down Expand Up @@ -400,6 +401,7 @@ table DurationLiteral {
table IntegerLiteral {
loc:SourceLocation;
value:int64;
typ:MonoType;
}

table FloatLiteral {
Expand Down
Loading

0 comments on commit bbfcaa4

Please sign in to comment.