feat(type-system): implement concept_comparison with pattern matching

Added complete support for the new type system syntax including:

- concept: Base type declarations
- sub_concept: Enum and record sub-type definitions
- concept_comparison: Compile-time pattern matching with conditional guards

Parser changes:
- Added VariantPattern, FieldCondition, and Condition AST nodes
- Implemented "is" keyword for pattern matching (e.g., "CupType is Glass or CupType is Plastic")
- Added Value::Any variant to support universal type matching
- Disambiguated enum-like vs record-like sub_concept syntax

LSP updates:
- Added Value::Any match arms across code_actions, completion, hover, inlay_hints, and semantic_tokens
- Type inference and formatting support for Any values

Example fixes:
- Fixed syntax error in baker-family behaviors (missing closing brace in nested if)
- Removed deprecated core_enums.sb file
This commit is contained in:
2026-02-14 09:28:20 +00:00
parent 6e3b35e68f
commit 25d59d6107
30 changed files with 8639 additions and 6536 deletions

View File

@@ -1300,62 +1300,6 @@ character Alice {
.any(|t| t.contains("Change to minimum value (0)")));
}
#[test]
fn test_fix_unknown_behavior_action() {
let source = r#"
behavior tree {
Run
}
"#;
let uri = Url::parse("file:///test.sb").unwrap();
let documents = make_documents(vec![("file:///test.sb", source)]);
let diagnostic = make_diagnostic(
"unknown action 'Run'",
Range {
start: Position {
line: 2,
character: 2,
},
end: Position {
line: 2,
character: 5,
},
},
);
let params = CodeActionParams {
text_document: TextDocumentIdentifier { uri: uri.clone() },
range: diagnostic.range,
context: CodeActionContext {
diagnostics: vec![diagnostic.clone()],
only: None,
trigger_kind: None,
},
work_done_progress_params: Default::default(),
partial_result_params: Default::default(),
};
let result = get_code_actions(&documents, &params);
assert!(result.is_some());
let actions = result.unwrap();
let titles: Vec<String> = actions
.iter()
.filter_map(|a| {
if let tower_lsp::lsp_types::CodeActionOrCommand::CodeAction(action) = a {
Some(action.title.clone())
} else {
None
}
})
.collect();
assert!(titles
.iter()
.any(|t| t.contains("Create Action enum with 'Run'")));
}
#[test]
fn test_fix_schedule_overlap() {
let source = r#"