Skip to content

Commit

Permalink
Internal improvements to subtyping and substitution (#146)
Browse files Browse the repository at this point in the history
- Change subtyping to use single state structure (rather than generic structures)
- Change substitution to use single immutable object for arguments
- `* extends * ? `, `infer U` and distributive extends
- Add `never` #136 + or folding
- Other stuff in PR description + changed tests
  • Loading branch information
kaleidawave authored May 31, 2024
1 parent 3760f36 commit ab2fcba
Show file tree
Hide file tree
Showing 84 changed files with 8,077 additions and 5,447 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ cargo test -p ezno-checker-specification -F all
If you want to regenerate the binary definition file

```shell
cargo run -p ezno-checker -F ezno-parser --example generate-cache ./checker/definitions/overrides.d.ts ./checker/definitions/internal.ts.d.bin
cargo run -p ezno-checker -F ezno-parser --example generate_cache ./checker/definitions/overrides.d.ts ./checker/definitions/internal.ts.d.bin
```

If you want to test the lexing and parsing in Ezno's parser
Expand All @@ -63,7 +63,7 @@ cargo run -p ezno-parser --example lex path/to/file.ts
### Bacon (script runner)

The [Bacon script runner](https://dystroy.org/bacon/) is configured for this repo. This can watch your files and re-run things like checks or tests on file change.
The configuration is managed in the [`bacon.toml`](./bacon.toml) file. The configuration has dedicated jobs for the checker specification tests mentioned above.
The configuration is managed in the [`bacon.toml`](./bacon.toml) file. The configuration has dedicated jobs for the checker specification tests mentioned above.

#### Installing Bacon

Expand All @@ -88,7 +88,7 @@ At any point, you can press `?` to see a list of all available hotkeys.

#### Adding new jobs to our Bacon config

New jobs can easily be added to our `bacon.toml` config if we find there are repetitive actions we're doing frequently.
New jobs can easily be added to our `bacon.toml` config if we find there are repetitive actions we're doing frequently.
[The Bacon documentation](https://dystroy.org/bacon/config/#jobs) does a good job of explaining how to do so.

### Useful commands
Expand Down
11 changes: 0 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ iterator-endiate = "0.2"
path-absolutize = { version = "3.0", features = ["use_unix_paths_on_wasm"] }
either = "1.6"
levenshtein = "1"
once_cell = "1.10"
ordered-float = "4.2"
map_vec = "0.5"

serde = { version = "1.0", features = ["derive"], optional = true }
simple-json-parser = "0.0.2"
Expand Down
4 changes: 4 additions & 0 deletions checker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ While the checker is indented for the Ezno toolchain and its parser, most (3/4)

#TODO `ASTImplementation`, `synthesis` folder rule

## Documentation

A sparse documentation of some to the internals of the functions, structures and processes exists in the `/documentation` folder.

## Testing

Set `EZNO_DEBUG` to any value to trace diagnostic information from the `crate::utils::notify!` macro (In powershell = `$Env:EZNO_DEBUG=1`)
Binary file modified checker/definitions/internal.ts.d.bin
Binary file not shown.
86 changes: 60 additions & 26 deletions checker/definitions/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ declare class Array<T> {
return undefined
} else {
const value = this[--this.length];
delete this[this.length];
// TODO this currently breaks value?
// delete this[this.length];
return value
}
}
Expand Down Expand Up @@ -143,6 +144,11 @@ declare class Array<T> {
// }
}

declare class Map<T, U> {
#keys: Array<T> = [];
#value: Array<T> = [];
}

declare class Math {
@Constant
static sin(x: number): number;
Expand Down Expand Up @@ -184,10 +190,18 @@ declare class String {

declare class Promise<T> { }

interface Response {
type ResponseBody = string;

declare class Response {
ok: boolean;

json(): Promise<any>;
// constructor(body?: ResponseBody, options: any);

// json(): Promise<any>;

// static json(data: any): Response {
// return new Response(JSON.stringify(data))
// }
}

declare class Console {
Expand Down Expand Up @@ -254,12 +268,27 @@ declare class Console {

declare const console: Console;

declare class Error {
message: string

// TODO `@AllowElidedNew`
constructor(message: string) {
this.message = message
}
}

declare class SyntaxError extends Error {
constructor() { super("syntax error") }
}

declare class JSON {
// TODO any temp
parse(input: string): any;
@Constant("json:parse", SyntaxError)
static parse(input: string): any;

// TODO any temp
stringify(input: any): string;
@Constant("json:stringify")
static stringify(input: any): string;
}

declare class Function {
Expand All @@ -271,6 +300,11 @@ declare class Symbols {
iterator: 199
}

declare class Proxy {
@Constant("proxy:constructor")
constructor(obj: any, cb: any);
}

declare class Object {
@Constant
static setPrototypeOf(on: object, to: object): object;
Expand All @@ -284,29 +318,29 @@ declare class Object {
// return n
// }

// static keys(on: object): Array<string> {
// const keys = [];
// for (const key in on) {
// keys.push(key);
// }
// return keys
// }
static keys(on: { [s: string]: any }): Array<string> {
const keys: Array<string> = [];
for (const key in on) {
keys.push(key);
}
return keys
}

// static values(on: object): Array<string> {
// const keys = [];
// for (const key in on) {
// keys.push(on[key]);
// }
// return keys
// }
static values(on: { [s: string]: any }): Array<any> {
const values: Array<any> = [];
for (const key in on) {
values.push(on[key]);
}
return values
}

// static entries(on: object): Array<[string, any]> {
// const keys = [];
// for (const key in on) {
// keys.push([key, on[key]]);
// }
// return keys
// }
static entries(on: { [s: string]: any }): Array<[string, any]> {
const entries: Array<[string, any]> = [];
for (const key in on) {
entries.push([key, on[key]]);
}
return entries
}

// static fromEntries(iterator: any): object {
// const obj = {};
Expand Down
Loading

0 comments on commit ab2fcba

Please sign in to comment.