Skip to content

Commit b65ab88

Browse files
committed
Update Warnings & Refinement Syntax
1 parent ecf9ed6 commit b65ab88

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

pages/annotations/refinements.md

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,21 @@ public class RefinementExamples {
3535

3636
## Predicate Syntax
3737

38-
Refinement predicates use a language similar to Java, where you can write boolean expressions using comparisons, logical connectives, arithmetic operators, conditional expressions, and calls to ghosts or aliases, which are covered in later sections.
38+
Refinement predicates use a language similar to Java, where you can write boolean expressions using comparisons, logical connectives, arithmetic operators, conditional expressions, ghosts and alias calls, and enum and field constants.
3939

4040
| Form | Syntax | Example |
4141
| --- | --- | --- |
42-
| Comparison | `==` `!=` `>` `>=` `<` `<=` | `@Refinement("x > 0") int x = 1;` |
43-
| Logical operators | `!` `&&` <code>&#124;&#124;</code> `-->` | `@Refinement("0 <= y && y <= 100") int y = 25;` |
44-
| Arithmetic | `+` `-` `*` `/` `%` | `@Refinement("v + 20 < 100") int v = 79;` |
45-
| Conditional | `cond ? e1 : e2` | `@Refinement("a > b ? _ == a : _ == b") int max(int a, int b)` |
46-
| Ghost and alias calls | `a(b)` `A(b)` | `@Refinement("Positive(_)") int c = 10;` |
47-
| Literals | `true` `false` `0` `1.5` | `@Refinement("_ == true") boolean ok = true;` |
48-
49-
LiquidJava currently only supports a small set of types in refinements:
42+
| Comparison operators | `==` `!=` `>` `>=` `<` `<=` | `@Refinement("x > 0") int x = 1` |
43+
| Logical operators | `!` `&&` <code>&#124;&#124;</code> `-->` | `@Refinement("0 <= y && y <= 100") int y = 25` |
44+
| Arithmetic operators | `+` `-` `*` `/` `%` | `@Refinement("v + 20 < 100") int v = 79` |
45+
| Ternary operator | `cond ? e1 : e2` | `@Refinement("a > b ? _ == a : _ == b") int max(int a, int b)` |
46+
| Ghost calls | `ghost(...args)` | `@Refinement("0 <= _ < size(this)") int index` |
47+
| Alias calls | `Alias(...args)` | `@Refinement("Positive(_)") int c = 10` |
48+
| Literals | `true` `false` `0` `1.5` | `@Refinement("true") void print()` |
49+
| Enums | `EnumType.VAlue` | `@Refinement("_ == Status.Open") Status status` |
50+
| Static final fields | `Type.FIELD` | `@Refinement("_ <= Integer.MAX_VALUE") int value` |
51+
52+
LiquidJava currently supports a small set of types in refinements:
5053
- The primitive types `int` `boolean` `long` `double` `float`
5154
- The boxed types `Boolean` `Integer` `Double`
55+
- Enum and static final field types whose values can be resolved as constants, such as `Status.Open` or `Integer.MAX_VALUE`

pages/diagnostics/warnings.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ Warnings do not affect the verification like errors, but they indicate that ther
1414
| --- | --- |
1515
| `ExternalClassNotFoundWarning` | A class referenced by an external refinement cannot be found |
1616
| `ExternalMethodNotFoundWarning` | A method referenced by an external refinement cannot be found in the target class |
17+
| `UnsatisfiableRefinementWarning` | A refinement is logically unsatisfiable and can never be true |
1718
| `CustomWarning` | Any other warning, such as reporting that Java compilation errors are present in the program |

0 commit comments

Comments
 (0)