typecheck: clarify missing CHECK TYPE expression
This commit is contained in:
@@ -141,12 +141,18 @@ SAY kind
|
|||||||
CHECK TYPE score IS NUMBER
|
CHECK TYPE score IS NUMBER
|
||||||
```
|
```
|
||||||
|
|
||||||
`CHECK TYPE` also gives a direct repair hint when `IS` is missing:
|
`CHECK TYPE` gives a direct repair hint when `IS` is missing:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
CHECK TYPE needs IS. Try: CHECK TYPE score IS NUMBER.
|
CHECK TYPE needs IS. Try: CHECK TYPE score IS NUMBER.
|
||||||
```
|
```
|
||||||
|
|
||||||
|
If the learner leaves out the expression as well, the checker explains all three required parts:
|
||||||
|
|
||||||
|
```text
|
||||||
|
CHECK TYPE needs an expression, IS, and a type. Try: CHECK TYPE score IS NUMBER.
|
||||||
|
```
|
||||||
|
|
||||||
If the learner writes `IS` but leaves out the expected type, Claro names the missing piece and shows a complete example:
|
If the learner writes `IS` but leaves out the expected type, Claro names the missing piece and shows a complete example:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ Ready now:
|
|||||||
- `TYPE OF` and `CHECK TYPE`
|
- `TYPE OF` and `CHECK TYPE`
|
||||||
- `CHECK TYPE` gives a direct repair hint when the learner forgets the `IS` keyword, for example `CHECK TYPE score` reports `CHECK TYPE needs IS. Try: CHECK TYPE score IS NUMBER.`
|
- `CHECK TYPE` gives a direct repair hint when the learner forgets the `IS` keyword, for example `CHECK TYPE score` reports `CHECK TYPE needs IS. Try: CHECK TYPE score IS NUMBER.`
|
||||||
- `CHECK TYPE` gives a direct repair hint when `IS` has no expected type, for example `CHECK TYPE score IS` reports `CHECK TYPE score needs a type after IS. Try: CHECK TYPE score IS NUMBER.`
|
- `CHECK TYPE` gives a direct repair hint when `IS` has no expected type, for example `CHECK TYPE score IS` reports `CHECK TYPE score needs a type after IS. Try: CHECK TYPE score IS NUMBER.`
|
||||||
|
- `CHECK TYPE` explains when the learner leaves out the expression as well, for example bare `CHECK TYPE` reports `CHECK TYPE needs an expression, IS, and a type. Try: CHECK TYPE score IS NUMBER.`
|
||||||
- `CHECK TYPE` rejects extra words after a valid expected type with a direct repair hint, so `CHECK TYPE score IS NUMBER TEXT` explains that only one type belongs in the check
|
- `CHECK TYPE` rejects extra words after a valid expected type with a direct repair hint, so `CHECK TYPE score IS NUMBER TEXT` explains that only one type belongs in the check
|
||||||
- `CHECK TYPE` rejects unknown expected type names with a beginner-facing list of supported types
|
- `CHECK TYPE` rejects unknown expected type names with a beginner-facing list of supported types
|
||||||
- typed list/map checks through `claro typecheck`, including a nested `LIST OF MAP` insertion example
|
- typed list/map checks through `claro typecheck`, including a nested `LIST OF MAP` insertion example
|
||||||
|
|||||||
@@ -76,6 +76,7 @@ Keep declared return types honest: `claro typecheck` now reports friendly diagno
|
|||||||
8q.1. Keep `CHECK TYPE` declarations understandable: `CHECK TYPE score IS` now gets a direct repair hint naming the missing expected type and showing a complete example.
|
8q.1. Keep `CHECK TYPE` declarations understandable: `CHECK TYPE score IS` now gets a direct repair hint naming the missing expected type and showing a complete example.
|
||||||
|
|
||||||
8q.2. Keep `CHECK TYPE` declarations unambiguous: extra words after a valid expected type now get a direct repair hint instead of being reported as an unknown type.
|
8q.2. Keep `CHECK TYPE` declarations unambiguous: extra words after a valid expected type now get a direct repair hint instead of being reported as an unknown type.
|
||||||
|
8q.3. Keep `CHECK TYPE` declarations complete: a bare `CHECK TYPE` now explains that the expression, `IS`, and expected type are all required, with a complete repair example.
|
||||||
|
|
||||||
### 1. Strong static types
|
### 1. Strong static types
|
||||||
|
|
||||||
|
|||||||
+2
-2
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
|||||||
|
CHECK TYPE
|
||||||
@@ -296,6 +296,9 @@ EXPECTED = {
|
|||||||
"tests/typecheck_missing_expected_type_bad.claro": [
|
"tests/typecheck_missing_expected_type_bad.claro": [
|
||||||
"tests/typecheck_missing_expected_type_bad.claro:2: CHECK TYPE score needs a type after IS. Try: CHECK TYPE score IS NUMBER.",
|
"tests/typecheck_missing_expected_type_bad.claro:2: CHECK TYPE score needs a type after IS. Try: CHECK TYPE score IS NUMBER.",
|
||||||
],
|
],
|
||||||
|
"tests/typecheck_missing_expression_bad.claro": [
|
||||||
|
"tests/typecheck_missing_expression_bad.claro:1: CHECK TYPE needs an expression, IS, and a type. Try: CHECK TYPE score IS NUMBER.",
|
||||||
|
],
|
||||||
"tests/typecheck_extra_check_type_tokens_bad.claro": [
|
"tests/typecheck_extra_check_type_tokens_bad.claro": [
|
||||||
"tests/typecheck_extra_check_type_tokens_bad.claro:2: CHECK TYPE score has extra text after type NUMBER. Keep only the expression, IS, and one type.",
|
"tests/typecheck_extra_check_type_tokens_bad.claro:2: CHECK TYPE score has extra text after type NUMBER. Keep only the expression, IS, and one type.",
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user