feat: post check element types of array and dict (#1417)

This commit is contained in:
Myriad-Dreamin 2025-02-27 14:20:36 +08:00 committed by GitHub
parent a191b7c852
commit ebfc93c104
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 23 additions and 16 deletions

View file

@ -87,9 +87,8 @@ fn check_signature<'a>(
}
// names
for (name, _) in sig_ins.named_params() {
// todo: reduce fields, fields ty
let field = ParamTy::new_untyped(name.clone(), ParamAttrs::named());
for (name, ty) in sig_ins.named_params() {
let field = ParamTy::new(ty.clone(), name.clone(), ParamAttrs::named());
receiver.insert(Ty::Param(field), !pol);
}

View file

@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs
description: Completion on ) (63..64)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/sig_dict.typ
snapshot_kind: text
---
[
{
@ -12,6 +11,9 @@ snapshot_kind: text
{
"kind": 5,
"label": "cap",
"labelDetails": {
"description": "\"butt\" | \"round\" | \"square\""
},
"sortText": "000",
"textEdit": {
"newText": "cap: ${1:}",
@ -30,6 +32,9 @@ snapshot_kind: text
{
"kind": 5,
"label": "paint",
"labelDetails": {
"description": "color"
},
"sortText": "004",
"textEdit": {
"newText": "paint: ${1:}",

View file

@ -3,7 +3,6 @@ source: crates/tinymist-query/src/completion.rs
description: Completion on ) (75..76)
expression: "JsonRepr::new_pure(results)"
input_file: crates/tinymist-query/src/fixtures/completion/sig_dict_rest.typ
snapshot_kind: text
---
[
{
@ -12,6 +11,9 @@ snapshot_kind: text
{
"kind": 5,
"label": "cap",
"labelDetails": {
"description": "\"butt\" | \"round\" | \"square\""
},
"sortText": "000",
"textEdit": {
"newText": "cap: ${1:}",

View file

@ -4,4 +4,4 @@ description: "Check on \"\\\"Test\\\"\" (34)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/text_font_element.typ
---
( ⪰ TextFont | "covers": Any | "name": Any | (TextFont | Array<TextFont>))
( ⪰ TextFont | "covers": (Type(regex) | "latin-in-cjk") | "name": TextFont | (TextFont | Array<TextFont>))

View file

@ -4,4 +4,4 @@ description: "Check on \"\\\"Test\\\"\" (31)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/text_font_element2.typ
---
( ⪰ ( ⪰ "Test" ⪯ (TextFont | Array<TextFont>)) ⪯ TextFont & "covers": Any & "name": Any)
( ⪰ ( ⪰ "Test" ⪯ (TextFont | Array<TextFont>)) ⪯ TextFont & "covers": (Type(regex) | "latin-in-cjk") & "name": TextFont)

View file

@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs
description: "Check on \")\" (82)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke.typ
snapshot_kind: text
---
( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any)
( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length)

View file

@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs
description: "Check on \"(\" (61)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke1.typ
snapshot_kind: text
---
( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any)
( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length)

View file

@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs
description: "Check on \"(\" (49)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/text_stroke3.typ
snapshot_kind: text
---
( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any)
( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length)

View file

@ -3,6 +3,5 @@ source: crates/tinymist-query/src/analysis.rs
description: "Check on \"(\" (85)"
expression: post_ty
input_file: crates/tinymist-query/src/fixtures/post_type_check/user_func_pos2.typ
snapshot_kind: text
---
( ⪰ "cap": Any | "dash": Any | "join": Any | "miter-limit": Any | "paint": Any | "thickness": Any)
( ⪰ "cap": ("butt" | "round" | "square") | "dash": ("dash-dotted" | "dashed" | "densely-dash-dotted" | "densely-dashed" | "densely-dotted" | "dotted" | "loosely-dash-dotted" | "loosely-dashed" | "loosely-dotted" | "solid" | {"array": Array<(Float | "dot")>, "phase": Length} | Array<(Float | "dot")>) | "join": ("bevel" | "miter" | "round") | "miter-limit": Float | "paint": Color | "thickness": Length)

View file

@ -620,9 +620,14 @@ pub struct ParamTy {
impl ParamTy {
/// Create an untyped field type
pub fn new_untyped(name: StrRef, attrs: ParamAttrs) -> Interned<Self> {
Self::new(Ty::Any, name, attrs)
}
/// Create a typed field type
pub fn new(ty: Ty, name: StrRef, attrs: ParamAttrs) -> Interned<Self> {
Interned::new(Self {
name,
ty: Ty::Any,
ty,
docs: None,
default: None,
attrs,