Commit a8b0cfb
authored
Fix issue where exhaustiveness check for pattern matching char was no… (#5744)
* Fix issue where exhaustiveness check for pattern matching char was not working
Fixes #5557
Fixes #5743
Exhaustiveness check for pattern matching relies on checking that the pattern does not lead to a type error.
Since char constants are represented internally as int, this causes an internal type error when processing patterns of the form 'x', where the constant is represented as `Pconst_integer` but the expected type is `char`.
This PR intercepts this situation and changes the expected type to `int`.
A cleaner solution would be to represent chars differently (but we can't change the AST), or make it official that char and int is the same type (and lose some abstraction).
* comment1 parent 9789cca commit a8b0cfb
File tree
5 files changed
+24
-0
lines changed- jscomp/ml
- lib/4.06.1
- unstable
5 files changed
+24
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1350 | 1350 | | |
1351 | 1351 | | |
1352 | 1352 | | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
1353 | 1358 | | |
1354 | 1359 | | |
1355 | 1360 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40301 | 40301 | | |
40302 | 40302 | | |
40303 | 40303 | | |
| 40304 | + | |
| 40305 | + | |
| 40306 | + | |
| 40307 | + | |
| 40308 | + | |
40304 | 40309 | | |
40305 | 40310 | | |
40306 | 40311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40301 | 40301 | | |
40302 | 40302 | | |
40303 | 40303 | | |
| 40304 | + | |
| 40305 | + | |
| 40306 | + | |
| 40307 | + | |
| 40308 | + | |
40304 | 40309 | | |
40305 | 40310 | | |
40306 | 40311 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
216688 | 216688 | | |
216689 | 216689 | | |
216690 | 216690 | | |
| 216691 | + | |
| 216692 | + | |
| 216693 | + | |
| 216694 | + | |
| 216695 | + | |
216691 | 216696 | | |
216692 | 216697 | | |
216693 | 216698 | | |
| |||
0 commit comments