-
Notifications
You must be signed in to change notification settings - Fork 187
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enforce bounds on numeric literals in type constructors
Fixes #145
- Loading branch information
Showing
34 changed files
with
391 additions
and
16 deletions.
There are no files selected for viewing
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
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i128: | ||
return i128(-170141183460469231731687303715884105729) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i128_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i128: | ||
return i128(170141183460469231731687303715884105728) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i16: | ||
return i16(-32769) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i16_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i16: | ||
return i16(32768) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i256: | ||
return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819969) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i256_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i256: | ||
return i256(57896044618658097711785492504343953926634992332820282019728792003956564819968) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i32: | ||
return i32(-2147483649) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i32_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i32: | ||
return i32(2147483648) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i64: | ||
return i64(-9223372036854775809) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i64_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i64: | ||
return i64(9223372036854775808) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i8: | ||
return i8(-129) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/i8_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> i8: | ||
return i8(128) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u128: | ||
return u128(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u128_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u128: | ||
return u128(340282366920938463463374607431768211456) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u16: | ||
return u16(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u16_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u16: | ||
return u16(65536) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u256: | ||
return u256(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u256_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u256: | ||
return u256(115792089237316195423570985008687907853269984665640564039457584007913129639936) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u32: | ||
return u32(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u32_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u32: | ||
return u32(4294967296) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u64: | ||
return u64(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u64_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u64: | ||
return u64(18446744073709551616) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_neg.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u8: | ||
return u8(-1) |
3 changes: 3 additions & 0 deletions
3
compiler/tests/fixtures/compile_errors/numeric_capacity_mismatch/u8_pos.fe
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,3 @@ | ||
contract Foo: | ||
pub def bar() -> u8: | ||
return u8(256) |
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,73 @@ | ||
contract Foo: | ||
|
||
pub def get_u8_min() -> u8: | ||
return u8(0) | ||
|
||
pub def get_u16_min() -> u16: | ||
return u16(0) | ||
|
||
pub def get_u32_min() -> u32: | ||
return u32(0) | ||
|
||
pub def get_u64_min() -> u64: | ||
return u64(0) | ||
|
||
pub def get_u128_min() -> u128: | ||
return u128(0) | ||
|
||
pub def get_u256_min() -> u256: | ||
return u256(0) | ||
|
||
pub def get_i8_min() -> i8: | ||
return i8(-128) | ||
|
||
pub def get_i16_min() -> i16: | ||
return i16(-32768) | ||
|
||
pub def get_i32_min() -> i32: | ||
return i32(-2147483648) | ||
|
||
pub def get_i64_min() -> i64: | ||
return i64(-9223372036854775808) | ||
|
||
pub def get_i128_min() -> i128: | ||
return i128(-170141183460469231731687303715884105728) | ||
|
||
pub def get_i256_min() -> i256: | ||
return i256(-57896044618658097711785492504343953926634992332820282019728792003956564819968) | ||
|
||
pub def get_u8_max() -> u8: | ||
return u8(255) | ||
|
||
pub def get_u16_max() -> u16: | ||
return u16(65535) | ||
|
||
pub def get_u32_max() -> u32: | ||
return u32(4294967295) | ||
|
||
pub def get_u64_max() -> u64: | ||
return u64(18446744073709551615) | ||
|
||
pub def get_u128_max() -> u128: | ||
return u128(340282366920938463463374607431768211455) | ||
|
||
pub def get_u256_max() -> u256: | ||
return u256(115792089237316195423570985008687907853269984665640564039457584007913129639935) | ||
|
||
pub def get_i8_max() -> i8: | ||
return i8(127) | ||
|
||
pub def get_i16_max() -> i16: | ||
return i16(32767) | ||
|
||
pub def get_i32_max() -> i32: | ||
return i32(2147483647) | ||
|
||
pub def get_i64_max() -> i64: | ||
return i64(9223372036854775807) | ||
|
||
pub def get_i128_max() -> i128: | ||
return i128(170141183460469231731687303715884105727) | ||
|
||
pub def get_i256_max() -> i256: | ||
return i256(57896044618658097711785492504343953926634992332820282019728792003956564819967) |
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,4 @@ | ||
Enforce bounds on numeric literals in type constructors. | ||
|
||
For instance calling `u8(1000)` or `i8(-250)` will give an error because | ||
the literals `1000` and `-250` do not fit into `u8` or `i8`. |
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
Oops, something went wrong.