Lower else-if chains to ordered branch arms

This commit is contained in:
Codex committed 2026-11-23 19:36:29 +08:00
1 parent c582451a5f
commit 095eef1370
29 files changed
+385 -95

No files matched your search

@@ -1,5 +1,7 @@
## @exec 符号
Regression fixture for separate else and if carriers forming nested branches.
`if n < 0`
`return -1`
@@ -0,0 +1,14 @@
{
"args": {
"数值": {
"decimal": "2",
"type": "int"
}
},
"function": "分类",
"stdout": "",
"value": {
"decimal": "2",
"type": "int"
}
}
@@ -0,0 +1,21 @@
## @exec 分类
`params(数值: Int)`
1. `if 数值 < 0`
`return -1`
2. **else if 数值 == 2**
`return 2`
3. *else if 1 / 0 > 0*
`return 3`
4. `else`
`return 4`
`end`
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "7",
"type": "int"
}
}
@@ -0,0 +1,9 @@
## @exec main
`if false`
`else if false`
`end`
`return 7`
@@ -0,0 +1,9 @@
{
"args": {},
"function": "main",
"stdout": "",
"value": {
"decimal": "5",
"type": "int"
}
}
@@ -0,0 +1,15 @@
## @exec main
`if false`
`else if true`
This selected arm contains prose only.
`else`
`return 9`
`end`
`return 5`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.duplicate_else"
]
}
@@ -0,0 +1,9 @@
## @exec main
`if false`
`else`
`else`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.else_if_after_else"
]
}
@@ -0,0 +1,9 @@
## @exec main
`if false`
`else`
`else if true`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unmatched_end"
]
}
@@ -0,0 +1,9 @@
## @exec main
`if false`
`else if true`
`end`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,3 @@
## @exec main
`else if`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unmatched_else_if"
]
}
@@ -0,0 +1,11 @@
## @exec main
`if false`
`while false`
`else if true`
`end`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.syntax"
]
}
@@ -0,0 +1,7 @@
## @exec main
`if false`
`else if true:`
`end`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unclosed_control"
]
}
@@ -0,0 +1,5 @@
## @exec main
`if false`
`else if true`
@@ -0,0 +1,5 @@
{
"codes": [
"sem.unmatched_else_if"
]
}
@@ -0,0 +1,3 @@
## @exec main
`else if true`
@@ -0,0 +1,7 @@
{
"function": "main",
"args": {},
"codes": [
"runtime.type"
]
}
@@ -0,0 +1,7 @@
## @exec main
`if false`
`else if 1`
`end`