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

@@ -183,11 +183,6 @@ fn find_references_in_declaration(
file_index,
));
},
| Declaration::Enum(e) => {
// Enums themselves don't reference symbols, but their values might be
// referenced Skip for now
let _ = (e, symbol_name, symbol_kind, file_index);
},
| Declaration::Use(_) => {
// Use statements are handled separately
},
@@ -319,10 +314,7 @@ fn find_references_in_value(
// Identifiers can reference characters, templates, enums, species
let matches_kind = matches!(
symbol_kind,
DeclKind::Character |
DeclKind::Template |
DeclKind::Enum |
DeclKind::Species
DeclKind::Character | DeclKind::Template | DeclKind::Species
);
if matches_kind {
@@ -667,24 +659,4 @@ relationship Friends { Alice as friend {} Bob as friend {} }
// Should find nothing
assert_eq!(refs.len(), 0);
}
#[test]
fn test_enum_field_references() {
let source = r#"
enum Mood { Happy, Sad }
character Alice { mood: Mood }
"#;
let file = parse(source);
let files = vec![file];
let refs = find_all_references(&files, "Mood", DeclKind::Enum);
// Should find: definition + field value reference
assert_eq!(refs.len(), 2);
let field_ref = refs
.iter()
.find(|r| r.context == ReferenceContext::FieldValue);
assert!(field_ref.is_some());
}
}