From fbf6aae7c56b62995f090052c9e1375b5d211788 Mon Sep 17 00:00:00 2001 From: Ben Date: Fri, 31 May 2024 12:27:25 +0100 Subject: [PATCH] Fix null span in template literal arguments (#150) * Last minute fixes - Fix null span used for template literal argument position - Allow aliases in key lookup - Add Record, at and join to env - Add more clarification to the tests --- checker/definitions/internal.ts.d.bin | Bin 26919 -> 28097 bytes checker/definitions/overrides.d.ts | 39 +++++++++++++++-------- checker/definitions/simple.d.ts | 16 ++++++++++ checker/specification/specification.md | 20 ++++++------ checker/specification/test.rs | 9 +++++- checker/src/features/template_literal.rs | 13 +++++--- checker/src/synthesis/definitions.rs | 13 ++------ checker/src/types/properties.rs | 12 ++++++- checker/src/types/subtyping.rs | 4 ++- 9 files changed, 84 insertions(+), 42 deletions(-) diff --git a/checker/definitions/internal.ts.d.bin b/checker/definitions/internal.ts.d.bin index 7269f27c0a2aa4ca66bdec8dc35496d9bda6f08a..8cfb2cd1938b78f4667cd2501747991f6b90d5dc 100644 GIT binary patch literal 28097 zcmdUY37lL-wfCuedzqd|Si&0Cn@I?rWHOTw!ZKuI2@=@?nTQ%7^vv`m4V~_xyC=yI zP~@?E%HydZ=tDL|4G72sWm5>NEKgC;5M`6)u|5IWM3L?N|FztEdu9@b=SP0ucazh% z>eP1X+^Vxw)xDEHsZ^famFrrXpWIU@=CgA|#>&>+`Ody2i);P8`Nf4&cfL1|pHfX^ z2NBr~Ac;eBwWT7T-Av>#fHWMLulANp)x5~XTZsG+AjzJ5tqYlM%8J|ykW4jKD^z<5 z`Kri^Eh4W2Bt5@UURGeiV^Jv2f}>3H`JSG9SFO6Z(pN>(*-0Yp07>tUcFIK*IDbo# zivZHJpubeht(;q_lq+Z}5V;Q^NsHJSk#R(1`p}P_LMh*kh`ToHDwk^cm9@o%?!{e8 zbA^(~IUwv}61Q1zrBJFZMviK&f+Wz9pD5A?kVcb6CW-v(1d$5>($HP*>RYCn^)C9X zh--}4De^Edj}yCTgtcA#KB~QrRr`nLdPUyaROB6ijI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aLkdWZLeAx@^BY=ZpB?pM!rE1x`Y_f`3sVxK&v8P3pjg zh@I$Dw)s~txI>H$V>)tt_1jIp)){D_-Rav|A>qN%zfp+cr21cR`L~PHa@YS(OP|}6 z{cDi^*H8YPywQJGrcXIL?;9i5=syF)0@C_=+XkAves_&6qjvV4GZFolW%}^HGZ~ux z?DOxbuuH)@w4@%yJ1fDoA6>{h;*sr>o#nCA_{V78cLwv%$wad0**GhhP*6%`=w!dV zve=XF@Y}K@cP_c$U$0@4d0_y}Zhg;2*Z$Xms-y;e@w;=rfd9?JcfK+wJh1~C{x1<3 B|Hc3S diff --git a/checker/definitions/overrides.d.ts b/checker/definitions/overrides.d.ts index 97d53088..83d4736d 100644 --- a/checker/definitions/overrides.d.ts +++ b/checker/definitions/overrides.d.ts @@ -1,6 +1,8 @@ @Constant declare function debug_type_independent(t: any): void; +// Eventually this will be merged with existing TS es5.d.ts files but for now is the standalone see #121 + interface ImportEnv { [key: string]: string | undefined; } @@ -128,22 +130,31 @@ declare class Array { // return false // } - // join(joiner: string = ","): string { - // const { length } = this; - // let i: number = 1; - // if (length === 0) { - // return "" - // } - // let s: string = "" + this[0]; - // while (i < length) { - // s += joiner; - // s += this[i++]; - // // debug_type_independent(s) - // } - // return s - // } + join(joiner: string = ","): string { + const { length } = this; + let i: number = 1; + if (length === 0) { + return "" + } + let s: string = "" + this[0]; + while (i < length) { + s += joiner; + s += this[i++]; + } + return s + } + + at(index: number) { + if (index < 0) { + return this[index + this.length] + } else { + return this[index] + } + } } +type Record = { [P in K]: T } + declare class Map { #keys: Array = []; #value: Array = []; diff --git a/checker/definitions/simple.d.ts b/checker/definitions/simple.d.ts index fe689338..deb1120b 100644 --- a/checker/definitions/simple.d.ts +++ b/checker/definitions/simple.d.ts @@ -131,6 +131,20 @@ declare class Array { // return false // } + join(joiner: string = ","): string { + const { length } = this; + let i: number = 1; + if (length === 0) { + return "" + } + let s: string = "" + this[0]; + while (i < length) { + s += joiner; + s += this[i++]; + } + return s + } + at(index: number) { if (index < 0) { return this[index + this.length] @@ -140,6 +154,8 @@ declare class Array { } } +type Record = { [P in K]: T } + declare class Map { #keys: Array = []; #value: Array = []; diff --git a/checker/specification/specification.md b/checker/specification/specification.md index b9b5a84a..9ec06bf8 100644 --- a/checker/specification/specification.md +++ b/checker/specification/specification.md @@ -2777,6 +2777,8 @@ what(2, 3) satisfies string; > Aka generic property keys +> Only works for `Record` atm. And while defined in the root environment, want to test the definition here as well + #### Simple key ```ts @@ -2794,11 +2796,9 @@ myRecord.hello; #### Assignment ```ts -type Record2 = { [P in K]: T } - -const x: Record2<"test", boolean> = { no: false }, - y: Record2<"test", boolean> = { test: 6 }, - z: Record2<"test", boolean> = { test: false }; +const x: Record<"test", boolean> = { no: false }, + y: Record<"test", boolean> = { test: 6 }, + z: Record<"test", boolean> = { test: false }; ``` - 'no' is not a property of { [\"test\"]: boolean } @@ -2808,16 +2808,14 @@ const x: Record2<"test", boolean> = { no: false }, #### Union and types as keys ```ts -type Record2 = { [P in K]: T } - -declare let obj1: Record2<"hi" | "hello", boolean>; +declare let obj1: Record<"hi" | "hello", boolean>; obj1.hi satisfies boolean; obj1.hello satisfies boolean; obj1.bye; -declare let obj2: Record2; +declare let obj2: Record; obj2.fine satisfies boolean; obj2[2]; ``` @@ -3267,12 +3265,12 @@ safeDivide(10, 0); ```ts function throwGreeting() { throw "Hello"; - return 5 + return "Unreachable!" } function doSomething() { throwGreeting() - const x = 2; + const unreachable = 2; } ``` diff --git a/checker/specification/test.rs b/checker/specification/test.rs index 1a5c7928..c597d974 100644 --- a/checker/specification/test.rs +++ b/checker/specification/test.rs @@ -7,7 +7,13 @@ use std::{ sync::{Arc, Mutex}, }; -use checker::{diagnostics, synthesis::EznoParser}; +use checker::{ + diagnostics, + source_map::{Nullable, SourceId}, + synthesis::EznoParser, +}; + +// This is here as it is used in the included `/specification.rs` use parser::ASTNode; mod specification { @@ -96,6 +102,7 @@ fn check_errors( .map(|diag| { let (reason, pos) = diag.reason_and_position(); if let Some(pos) = pos { + assert_ne!(pos.source, SourceId::NULL); // TODO position reason } else { diff --git a/checker/src/features/template_literal.rs b/checker/src/features/template_literal.rs index d913c249..643a8c68 100644 --- a/checker/src/features/template_literal.rs +++ b/checker/src/features/template_literal.rs @@ -85,11 +85,16 @@ where ); static_part_count += 1; } - p @ TemplateLiteralPart::Dynamic(_) => { + TemplateLiteralPart::Dynamic(expression) => { + let position = + A::expression_position(expression).with_source(environment.get_source()); arguments.push(SynthesisedArgument { - value: part_to_type(p, environment, checking_data), - // TODO position - position: source_map::Nullable::NULL, + value: part_to_type( + TemplateLiteralPart::Dynamic(expression), + environment, + checking_data, + ), + position, spread: false, }); } diff --git a/checker/src/synthesis/definitions.rs b/checker/src/synthesis/definitions.rs index 215bc68d..56b63418 100644 --- a/checker/src/synthesis/definitions.rs +++ b/checker/src/synthesis/definitions.rs @@ -117,16 +117,6 @@ pub(super) fn type_definition_file( StatementOrDeclaration::Declaration(Declaration::Class(class)) => { register_statement_class_with_members(&class.on, &mut environment, checking_data); } - StatementOrDeclaration::Declaration(Declaration::TypeAlias(TypeAlias { - name: _, - references: _, - parameters, - position: _, - })) => { - if let Some(_parameters) = parameters { - todo!("set parameters") - } - } StatementOrDeclaration::Declaration(Declaration::Function(function)) => { crate::synthesis::variables::register_variable_identifier( &function.on.name.identifier, @@ -139,6 +129,9 @@ pub(super) fn type_definition_file( }, ); } + StatementOrDeclaration::Declaration(Declaration::TypeAlias(TypeAlias { .. })) => { + crate::utilities::notify!("Don't think anything needed here"); + } StatementOrDeclaration::Statement( Statement::Comment(..) | Statement::Empty(..) | Statement::AestheticSemiColon(..), ) => {} diff --git a/checker/src/types/properties.rs b/checker/src/types/properties.rs index 094cf8ba..fc6d0783 100644 --- a/checker/src/types/properties.rs +++ b/checker/src/types/properties.rs @@ -1439,7 +1439,8 @@ pub(crate) fn key_matches( ) } else if let Type::RootPolyType(PolyNature::MappedGeneric { eager_fixed: to, .. - }) = want_ty + }) + | Type::AliasTo { to, .. } = want_ty { key_matches( (key, key_type_arguments), @@ -1470,6 +1471,15 @@ pub(crate) fn key_matches( if let Type::RootPolyType(PolyNature::MappedGeneric { eager_fixed: to, .. }) = key_type { + crate::utilities::notify!("Special behavior?"); + return key_matches( + (&PropertyKey::Type(*to), key_type_arguments), + (want, want_type_arguments), + types, + ); + } + + if let Type::AliasTo { to, .. } = key_type { return key_matches( (&PropertyKey::Type(*to), key_type_arguments), (want, want_type_arguments), diff --git a/checker/src/types/subtyping.rs b/checker/src/types/subtyping.rs index 5efd8192..ee50bcbc 100644 --- a/checker/src/types/subtyping.rs +++ b/checker/src/types/subtyping.rs @@ -1248,7 +1248,9 @@ fn subtype_properties( if let Some(GenericChainLink::Link { ref from, parent_link, value: _ }) = base_type_arguments { - assert!(parent_link.is_none(), "TODO recursive get_from"); + if parent_link.is_none() { + crate::utilities::notify!("TODO recursive get_from"); + } *from } else { base_type