diff --git a/crates/tinymist-query/src/analysis.rs b/crates/tinymist-query/src/analysis.rs index a3682043..6b78c6de 100644 --- a/crates/tinymist-query/src/analysis.rs +++ b/crates/tinymist-query/src/analysis.rs @@ -111,7 +111,7 @@ mod expr_tests { let result = ctx.shared_().expr_stage(&source); let mut docstrings = result.docstrings.iter().collect::>(); - docstrings.sort_by(|x, y| x.0.weak_cmp(y.0)); + docstrings.sort_by(|x, y| x.0.cmp(y.0)); let mut docstrings = docstrings .into_iter() .map(|(ident, expr)| { @@ -136,7 +136,7 @@ mod expr_tests { let result = ctx.shared_().expr_stage(&source); let mut resolves = result.resolves.iter().collect::>(); - resolves.sort_by(|x, y| x.1.decl.weak_cmp(&y.1.decl)); + resolves.sort_by(|x, y| x.1.decl.cmp(&y.1.decl)); let mut resolves = resolves .into_iter() diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@destructing.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@destructing.typ.snap index a16b1ec2..c0ab0442 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@destructing.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@destructing.typ.snap @@ -5,11 +5,11 @@ input_file: crates/tinymist-query/src/fixtures/expr_of/destructing.typ --- = resolves Var(a)@6..7 in /s0.typ -> Var(a)@6..7 in /s0.typ, root Var(a)@6..7 in /s0.typ, val: None -Var(a)@28..29 in /s0.typ -> Var(a)@28..29 in /s0.typ, root Var(a)@28..29 in /s0.typ, val: None -IdentRef(a)@40..41 in /s0.typ -> Var(a)@6..7 in /s0.typ, root Var(a)@6..7 in /s0.typ, val: None Var(b)@9..10 in /s0.typ -> Var(b)@9..10 in /s0.typ, root Var(b)@9..10 in /s0.typ, val: None +Var(a)@28..29 in /s0.typ -> Var(a)@28..29 in /s0.typ, root Var(a)@28..29 in /s0.typ, val: None Var(b)@31..32 in /s0.typ -> Var(b)@31..32 in /s0.typ, root Var(b)@31..32 in /s0.typ, val: None IdentRef(b)@37..38 in /s0.typ -> Var(b)@9..10 in /s0.typ, root Var(b)@9..10 in /s0.typ, val: None +IdentRef(a)@40..41 in /s0.typ -> Var(a)@6..7 in /s0.typ, root Var(a)@6..7 in /s0.typ, val: None = exports a -> Var(a)@28..29 in /s0.typ b -> Var(b)@31..32 in /s0.typ diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@dict.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@dict.typ.snap index c0ad8ce7..3aeba507 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@dict.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@dict.typ.snap @@ -4,8 +4,8 @@ expression: "snap.join(\"\\n\")" input_file: crates/tinymist-query/src/fixtures/expr_of/dict.typ --- = resolves -Var(x)@17..18 in /s0.typ -> Var(x)@17..18 in /s0.typ, root Var(x)@17..18 in /s0.typ, val: None Var(z)@5..6 in /s0.typ -> Var(z)@5..6 in /s0.typ, root Var(z)@5..6 in /s0.typ, val: None +Var(x)@17..18 in /s0.typ -> Var(x)@17..18 in /s0.typ, root Var(x)@17..18 in /s0.typ, val: None IdentRef(z)@28..29 in /s0.typ -> Var(z)@5..6 in /s0.typ, root Var(z)@5..6 in /s0.typ, val: None IdentRef(z)@40..41 in /s0.typ -> Var(z)@5..6 in /s0.typ, root Var(z)@5..6 in /s0.typ, val: None = exports diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@func.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@func.typ.snap index c22ad7db..449817d1 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@func.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@func.typ.snap @@ -4,10 +4,10 @@ expression: "snap.join(\"\\n\")" input_file: crates/tinymist-query/src/fixtures/expr_of/func.typ --- = resolves +Var(x)@5..6 in /s0.typ -> Var(x)@5..6 in /s0.typ, root Var(x)@5..6 in /s0.typ, val: None +Func(f)@17..18 in /s0.typ -> Func(f)@17..18 in /s0.typ, root Func(f)@17..18 in /s0.typ, val: None Var(a)@19..20 in /s0.typ -> Var(a)@19..20 in /s0.typ, root Var(a)@19..20 in /s0.typ, val: None IdentRef(a)@24..25 in /s0.typ -> Var(a)@19..20 in /s0.typ, root Var(a)@19..20 in /s0.typ, val: None -Func(f)@17..18 in /s0.typ -> Func(f)@17..18 in /s0.typ, root Func(f)@17..18 in /s0.typ, val: None -Var(x)@5..6 in /s0.typ -> Var(x)@5..6 in /s0.typ, root Var(x)@5..6 in /s0.typ, val: None = exports f -> Func(f)@17..18 in /s0.typ x -> Var(x)@5..6 in /s0.typ diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias.typ.snap index ad2a1ce0..9f576166 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias.typ.snap @@ -7,8 +7,8 @@ input_file: crates/tinymist-query/src/fixtures/expr_of/import_alias.typ PathStem(base)@8..18 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@20..24 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(base)@33..43 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None -IdentRef(base)@52..56 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None ModuleAlias(foo)@47..50 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None +IdentRef(base)@52..56 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(foo)@59..62 in /s0.typ -> ModuleAlias(foo)@47..50 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None = exports base -> ref(PathStem(base), step = Module(base), root = Module(base)) diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias_both.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias_both.typ.snap index 8d763b94..65b9cee8 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias_both.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_alias_both.typ.snap @@ -7,11 +7,11 @@ input_file: crates/tinymist-query/src/fixtures/expr_of/import_alias_both.typ PathStem(base)@8..18 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@20..24 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(base)@33..43 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None -IdentRef(base)@62..66 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None ModuleAlias(foo)@47..50 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None -ImportAlias(foo)@57..60 in /s0.typ -> Import(x)@52..53 in /s0.typ, root (ModuleAlias(foo)).IdentRef(x), val: None -IdentRef(foo)@69..72 in /s0.typ -> ImportAlias(foo)@57..60 in /s0.typ, root (ModuleAlias(foo)).IdentRef(x), val: None Import(x)@52..53 in /s0.typ -> (ModuleAlias(foo)).IdentRef(x), root (ModuleAlias(foo)).IdentRef(x), val: None +ImportAlias(foo)@57..60 in /s0.typ -> Import(x)@52..53 in /s0.typ, root (ModuleAlias(foo)).IdentRef(x), val: None +IdentRef(base)@62..66 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None +IdentRef(foo)@69..72 in /s0.typ -> ImportAlias(foo)@57..60 in /s0.typ, root (ModuleAlias(foo)).IdentRef(x), val: None = exports base -> ref(PathStem(base), step = Module(base), root = Module(base)) foo -> ref(ImportAlias(foo), step = Import(x), root = (ModuleAlias(foo)).IdentRef(x)) diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_by_ident.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_by_ident.typ.snap index f33efe2c..957c2e2e 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_by_ident.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_by_ident.typ.snap @@ -5,8 +5,8 @@ input_file: crates/tinymist-query/src/fixtures/expr_of/import_by_ident.typ --- = resolves ModuleImport(..)@1..23 in /s2.typ -> Module(derive)@0..0 in /derive.typ, root Module(derive)@0..0 in /derive.typ, val: None -ModuleImport(..)@25..39 in /s2.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(derive)@8..20 in /s2.typ -> Module(derive)@0..0 in /derive.typ, root Module(derive)@0..0 in /derive.typ, val: None +ModuleImport(..)@25..39 in /s2.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(f)@41..42 in /s2.typ -> Func(f)@0..0 in /base.typ, root Func(f)@0..0 in /base.typ, val: None = exports base -> ref(PathStem(base), step = Module(base), root = Module(base)) diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident.typ.snap index 2ac736f9..5a262d8b 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident.typ.snap @@ -4,12 +4,12 @@ expression: "snap.join(\"\\n\")" input_file: crates/tinymist-query/src/fixtures/expr_of/import_ident.typ --- = resolves -ModuleImport(..)@26..46 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None PathStem(base)@8..18 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@20..24 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None +ModuleImport(..)@26..46 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(base)@33..43 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None -IdentRef(base)@48..52 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None Import(x)@45..46 in /s0.typ -> (ModuleImport(..)).IdentRef(x), root (ModuleImport(..)).IdentRef(x), val: None +IdentRef(base)@48..52 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(x)@55..56 in /s0.typ -> Import(x)@45..46 in /s0.typ, root (ModuleImport(..)).IdentRef(x), val: None = exports base -> ref(PathStem(base), step = Module(base), root = Module(base)) diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident_alias.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident_alias.typ.snap index 91445df1..a27fc228 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident_alias.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_ident_alias.typ.snap @@ -4,14 +4,14 @@ expression: "snap.join(\"\\n\")" input_file: crates/tinymist-query/src/fixtures/expr_of/import_ident_alias.typ --- = resolves -ModuleImport(..)@26..53 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None PathStem(base)@8..18 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@20..24 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None +ModuleImport(..)@26..53 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(base)@33..43 in /s0.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None -IdentRef(base)@55..59 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None -ImportAlias(foo)@50..53 in /s0.typ -> Import(x)@45..46 in /s0.typ, root (ModuleImport(..)).IdentRef(x), val: None -IdentRef(foo)@62..65 in /s0.typ -> ImportAlias(foo)@50..53 in /s0.typ, root (ModuleImport(..)).IdentRef(x), val: None Import(x)@45..46 in /s0.typ -> (ModuleImport(..)).IdentRef(x), root (ModuleImport(..)).IdentRef(x), val: None +ImportAlias(foo)@50..53 in /s0.typ -> Import(x)@45..46 in /s0.typ, root (ModuleImport(..)).IdentRef(x), val: None +IdentRef(base)@55..59 in /s0.typ -> PathStem(base)@8..18 in /s0.typ, root Module(base)@0..0 in /base.typ, val: None +IdentRef(foo)@62..65 in /s0.typ -> ImportAlias(foo)@50..53 in /s0.typ, root (ModuleImport(..)).IdentRef(x), val: None = exports base -> ref(PathStem(base), step = Module(base), root = Module(base)) foo -> ref(ImportAlias(foo), step = Import(x), root = (ModuleImport(..)).IdentRef(x)) diff --git a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_star.typ.snap b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_star.typ.snap index da903385..cea79ac7 100644 --- a/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_star.typ.snap +++ b/crates/tinymist-query/src/fixtures/expr_of/snaps/scope@import_star.typ.snap @@ -4,9 +4,9 @@ expression: "snap.join(\"\\n\")" input_file: crates/tinymist-query/src/fixtures/expr_of/import_star.typ --- = resolves -ModuleImport(..)@26..46 in /s1.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None PathStem(base)@8..18 in /s1.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@20..24 in /s1.typ -> PathStem(base)@8..18 in /s1.typ, root Module(base)@0..0 in /base.typ, val: None +ModuleImport(..)@26..46 in /s1.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None ImportPath(base)@33..43 in /s1.typ -> Module(base)@0..0 in /base.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(base)@48..52 in /s1.typ -> PathStem(base)@8..18 in /s1.typ, root Module(base)@0..0 in /base.typ, val: None IdentRef(x)@55..56 in /s1.typ -> Var(x)@0..0 in /base.typ, root Var(x)@0..0 in /base.typ, val: None diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn.typ.snap index 80986348..bca10d4a 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn.typ.snap @@ -3,11 +3,11 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/annotation_fn.typ --- -"args" = Args +"touying-fn-wrapper" = ((( ⪯ Type(function)), "max-repetitions": ( ⪯ Type(int)), "repetitions": ( ⪯ Type(int)), ...: ( ⪯ Any)) => None).with(..("max-repetitions": None, "repetitions": None) => any) "fn" = Any "max-repetitions" = None "repetitions" = None -"touying-fn-wrapper" = ((( ⪯ Type(function)), "max-repetitions": ( ⪯ Type(int)), "repetitions": ( ⪯ Type(int)), ...: ( ⪯ Any)) => None).with(..("max-repetitions": None, "repetitions": None) => any) +"args" = Args --- 162..180 -> @touying-fn-wrapper 181..183 -> @fn diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn2.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn2.typ.snap index aa9a3fdc..9c7186c5 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn2.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_fn2.typ.snap @@ -4,9 +4,9 @@ expression: result input_file: crates/tinymist-query/src/fixtures/type_check/annotation_fn2.typ --- "args" = Any -"args" = Args -"fn" = Any "fn-wrapper" = (( ⪯ (Type(function) | (...: Any) => Any)), ...: ( ⪯ Any)) => None +"fn" = Any +"args" = Args --- 107..117 -> @fn-wrapper 118..120 -> @fn diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_sum.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_sum.typ.snap index e555fb06..f644caa3 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_sum.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_sum.typ.snap @@ -3,8 +3,8 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/annotation_sum.typ --- -"args" = Args "sum" = (...: ( ⪯ Array)) => None +"args" = Args --- 65..68 -> @sum 71..75 -> @args diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_var.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_var.typ.snap index e73be875..b42869e6 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_var.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@annotation_var.typ.snap @@ -5,10 +5,10 @@ input_file: crates/tinymist-query/src/fixtures/type_check/annotation_var.typ --- "x" = Any "y" = Any -"" = (Any, Any) => Any -"f" = Any "mapper" = (Type(function) | (Any, Any) => Any) +"" = (Any, Any) => Any "x" = Any +"f" = Any --- 56..62 -> @mapper 65..83 -> @ diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@bug_cite_func_infer.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@bug_cite_func_infer.typ.snap index 2411226c..0c9ca030 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@bug_cite_func_infer.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@bug_cite_func_infer.typ.snap @@ -4,8 +4,8 @@ expression: result input_file: crates/tinymist-query/src/fixtures/type_check/bug_cite_func_infer.typ --- "cite_prose" = (( ⪯ (RefLabel))) => Element(ref) -"cite_prose_different_name" = (( ⪯ (RefLabel))) => Element(ref) "labl" = Any +"cite_prose_different_name" = (( ⪯ (RefLabel))) => Element(ref) "labl" = Any --- 5..15 -> @cite_prose diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@confusing-name.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@confusing-name.typ.snap index cfbf4bb6..6ebb02cf 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@confusing-name.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@confusing-name.typ.snap @@ -3,12 +3,12 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/confusing-name.typ --- -"date" = Any -"info" = Any -"master-cover" = ((Any, "x": Any) => TypeBinary { operands: (Any, TypeBinary { operands: ({"submit-date": 0}, Any), op: Add }), op: Assign }).with(..("x": Any) => any) "x" = (Any) => Any +"date" = Any "x" = Any "x" = Any +"master-cover" = ((Any, "x": Any) => TypeBinary { operands: (Any, TypeBinary { operands: ({"submit-date": 0}, Any), op: Add }), op: Assign }).with(..("x": Any) => any) +"info" = Any "x" = Any --- 5..6 -> @x diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named.typ.snap index 62dd8626..d6c04f64 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named.typ.snap @@ -3,8 +3,8 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/fn_named.typ --- -"d" = ( ⪰ 3 | Type(int)) "foo" = (("d": Any) => Any).with(..("d": 3) => any) +"d" = ( ⪰ 3 | Type(int)) "x" = 3 --- 5..8 -> @foo diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named2.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named2.typ.snap index 197d6e04..35bc50c0 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named2.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named2.typ.snap @@ -3,9 +3,9 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/fn_named2.typ --- -"a" = Any -"foo" = (("a": Any) => Any).with(..("a": 1) => any) "val" = 1 +"foo" = (("a": Any) => Any).with(..("a": 1) => any) +"a" = Any "x" = Any --- 5..8 -> @val diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named3.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named3.typ.snap index 80ef9b5e..fa592047 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named3.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named3.typ.snap @@ -3,9 +3,9 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/fn_named3.typ --- -"b" = ( ⪰ TypeUnary { lhs: 2, op: Return } | TypeUnary { lhs: 2, op: Return }) -"foo" = (("b": Any) => Any).with(..("b": TypeUnary { lhs: 2, op: Return }) => any) "fun" = () => TypeUnary { lhs: 2, op: Return } +"foo" = (("b": Any) => Any).with(..("b": TypeUnary { lhs: 2, op: Return }) => any) +"b" = ( ⪰ TypeUnary { lhs: 2, op: Return } | TypeUnary { lhs: 2, op: Return }) "x" = TypeUnary { lhs: 2, op: Return } --- 5..8 -> @fun diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named4.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named4.typ.snap index 9ccd6567..4df53255 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named4.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@fn_named4.typ.snap @@ -3,9 +3,9 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/fn_named4.typ --- -"c" = ( ⪰ (3 | {"x": 3}.x) | (3 | {"x": 3}.x)) "dict" = {"x": 3} "foo" = (("c": Any) => Any).with(..("c": (3 | {"x": 3}.x)) => any) +"c" = ( ⪰ (3 | {"x": 3}.x) | (3 | {"x": 3}.x)) "x" = (3 | {"x": 3}.x) --- 5..9 -> @dict diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template.typ.snap index 19a0c36a..d12ca4be 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template.typ.snap @@ -3,8 +3,8 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/sig_template.typ --- -"content" = Any "tmpl" = (Any) => Any +"content" = Any --- 5..9 -> @tmpl 10..17 -> @content diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template_set.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template_set.typ.snap index 4f3105cf..7483c349 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template_set.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@sig_template_set.typ.snap @@ -3,11 +3,11 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/sig_template_set.typ --- -"authors" = () -"class" = ( ⪰ "article" | "article" | "letter" | "article" | "letter") -"content" = Any -"font" = None "tmpl" = ((Any, "authors": ( ⪯ (Type(array) | Type(str))), "class": Any, "font": ( ⪯ (TextFont | Array))) => Any).with(..("authors": (), "class": "article", "font": None) => any) +"content" = Any +"authors" = () +"font" = None +"class" = ( ⪰ "article" | "article" | "letter" | "article" | "letter") --- 5..9 -> @tmpl 10..17 -> @content diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@tuple_map.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@tuple_map.typ.snap index c3a27954..639cc52e 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@tuple_map.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@tuple_map.typ.snap @@ -3,11 +3,11 @@ source: crates/tinymist-query/src/analysis.rs expression: result input_file: crates/tinymist-query/src/fixtures/type_check/tuple_map.typ --- -"" = (( ⪯ (Type(bytes) | Type(decimal) | Type(float) | Type(int) | Type(label) | Type(str) | Type(type) | Type(version)))) => Type(str) "a" = (1, ) -"b" = (Type(str), ) "f" = (( ⪯ (Type(bytes) | Type(decimal) | Type(float) | Type(int) | Type(label) | Type(str) | Type(type) | Type(version)))) => Type(str) +"" = (( ⪯ (Type(bytes) | Type(decimal) | Type(float) | Type(int) | Type(label) | Type(str) | Type(type) | Type(version)))) => Type(str) "x" = Any +"b" = (Type(str), ) --- 5..6 -> @a 20..21 -> @f diff --git a/crates/tinymist-query/src/fixtures/type_check/snaps/test@with.typ.snap b/crates/tinymist-query/src/fixtures/type_check/snaps/test@with.typ.snap index 7296021b..923c72d7 100644 --- a/crates/tinymist-query/src/fixtures/type_check/snaps/test@with.typ.snap +++ b/crates/tinymist-query/src/fixtures/type_check/snaps/test@with.typ.snap @@ -4,8 +4,8 @@ expression: result input_file: crates/tinymist-query/src/fixtures/type_check/with.typ --- "f" = (Any) => Any -"g" = ((Any) => Any).with(..(1) => any) "x" = ( ⪰ Type(int) | Type(int)) +"g" = ((Any) => Any).with(..(1) => any) "x" = 1 --- 5..6 -> @f diff --git a/crates/tinymist-query/src/syntax/def.rs b/crates/tinymist-query/src/syntax/def.rs index 7f1ab50f..28b34bb6 100644 --- a/crates/tinymist-query/src/syntax/def.rs +++ b/crates/tinymist-query/src/syntax/def.rs @@ -442,18 +442,6 @@ impl Decl { src.range(self.span()) } - pub fn weak_cmp(&self, other: &Self) -> std::cmp::Ordering { - self.name() - .cmp(other.name()) - .then_with(|| match (self, other) { - (Self::Generated(l), Self::Generated(r)) => l.0 .0.cmp(&r.0 .0), - (Self::Docs(l), Self::Docs(r)) => { - l.var.cmp(&r.var).then_with(|| l.base.weak_cmp(&r.base)) - } - _ => self.span().number().cmp(&other.span().number()), - }) - } - pub fn as_def(this: &Interned, val: Option) -> Interned { let def: Expr = this.clone().into(); Interned::new(RefExpr { @@ -465,6 +453,25 @@ impl Decl { } } +impl Ord for Decl { + fn cmp(&self, other: &Self) -> std::cmp::Ordering { + let base = match (self, other) { + (Self::Generated(l), Self::Generated(r)) => l.0 .0.cmp(&r.0 .0), + (Self::Module(l), Self::Module(r)) => l.fid.cmp(&r.fid), + (Self::Docs(l), Self::Docs(r)) => l.var.cmp(&r.var).then_with(|| l.base.cmp(&r.base)), + _ => self.span().number().cmp(&other.span().number()), + }; + + base.then_with(|| self.name().cmp(other.name())) + } +} + +impl PartialOrd for Decl { + fn partial_cmp(&self, other: &Self) -> Option { + Some(self.cmp(other)) + } +} + impl From for Expr { fn from(decl: Decl) -> Self { Expr::Decl(decl.into()) diff --git a/crates/tinymist-query/src/ty/def.rs b/crates/tinymist-query/src/ty/def.rs index 9c77a483..a4e1bf5c 100644 --- a/crates/tinymist-query/src/ty/def.rs +++ b/crates/tinymist-query/src/ty/def.rs @@ -450,7 +450,7 @@ pub struct TypeVar { impl Ord for TypeVar { fn cmp(&self, other: &Self) -> std::cmp::Ordering { // todo: buggy - self.def.weak_cmp(&other.def) + self.def.cmp(&other.def) } }