RuleScript v1.3.0
RuleScript v1.3.0
Highlights
RuleScript v1.3.0 adds non-fallthrough switch statements, multi-value and guarded cases, a script-level null literal, and switch-specific semantic diagnostics while preserving existing script and host API compatibility.
switch status:
case "ok":
result = "Continue";
case "warning", "error" when retryCount <= 3:
result = "Inspect";
case "warning" when retryCount > 3:
result = "Escalate";
case null:
result = "Missing status";
default:
result = "Unknown status";
endswitch
Switch Behavior
- The switch expression is evaluated exactly once.
- The first eligible case executes once without fallthrough;
breakis not required. - Comma-separated labels and consecutive empty labels can share a body.
- A
whenguard runs only after its label matches and must evaluate tobool. defaultis optional, unique, and must be last.endcan replaceendswitch.- Synchronous and asynchronous execution are supported.
Analysis and Public API
- Added
RuleScriptDiagnosticCodes.DuplicateCase(RS2006). - Added
RuleScriptDiagnosticCodes.MissingDefaultBranch(RS2007). - Added switch/case type compatibility and guard-type analysis.
- Added public
SwitchStatement,SwitchCase, andSwitchLabelAST records. - Added
Null,Switch,Case,Default,When, andEndSwitchtoken types. - Updated symbol collection for variables declared in case and default bodies.
Compatibility
Existing scripts and v1.2.0 host integrations remain compatible unless a script used a newly reserved word as an identifier. New reserved words are switch, case, default, when, endswitch, and null.
Validation
- Release build: 0 warnings and 0 errors.
- Test suite: 399 passed, 0 failed, 0 skipped.
- Package version:
1.3.0.
For complete syntax and API documentation, see the Language Guide, Debugging and Analysis, and API Reference by Class.