Skip to content

Commit

Permalink
Fixes around disjoint implementation (#209)
Browse files Browse the repository at this point in the history
- Change over intersection to use disjoint function
- Change ranges back to LessThan & GreaterThan
- Narrowing fix
- Add modulo_class and float_range helpers
- Extract helpers and operator modules
- Literal on object
- Indentation in specification
- Disjoint on template literals
- Move specification tests
  • Loading branch information
kaleidawave authored Nov 13, 2024
1 parent bba226c commit dab8faf
Show file tree
Hide file tree
Showing 66 changed files with 3,888 additions and 2,434 deletions.
1 change: 1 addition & 0 deletions .github/workflows/clippy-rustfmt-fix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- uses: actions/cache@v4
with:
path: ${{ env.CACHE_PATHS }}
Expand Down
32 changes: 17 additions & 15 deletions .github/workflows/performance-and-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ jobs:
env:
CARGO_PROFILE_RELEASE_DEBUG: true

- name: Get base ezno
if: github.ref_name != 'main'
uses: actions/download-artifact@v4
continue-on-error: true
with:
name: latest-checker
path: previous-ezno
# TODO need to lookup existing workflow on main
# even if this worked, it might have issues with newer features added in this run
# - name: Get base ezno
# if: github.ref_name != 'main'
# uses: actions/download-artifact@v4
# continue-on-error: true
# with:
# name: latest-checker
# path: previous-ezno

- name: Set compilers
id: compilers
Expand Down Expand Up @@ -197,16 +199,16 @@ jobs:
curl -sS $url > input.js
echo "::group::Comparison"
hyperfine \
hyperfine -i \
-L compiler ${{ steps.compilers.outputs.BINARIES }} \
'{compiler} ast-explorer full input.js --timings'
echo "::endgroup::"
done
- name: Upload checker
if: github.ref == 'main'
uses: actions/upload-artifact@v4
with:
name: latest-checker
path: target/release/ezno
retention-days: 90
# - name: Upload checker
# if: github.ref == 'main'
# uses: actions/upload-artifact@v4
# with:
# name: latest-checker
# path: target/release/ezno
# retention-days: 90
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:

- name: Run checker specification
if: (steps.changes.outputs.checker == 'true' && github.event_name != 'pull_request') || github.ref_name == 'main'
run: cargo test
run: cargo test -p ezno-checker-specification

- name: Run checker specification (w/ staging)
if: steps.changes.outputs.checker == 'true' && github.event_name == 'pull_request'
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ What Ezno is:

What Ezno is not
- **eNZo, the Z is in front of the N** (pronounce as 'Fresno' without the 'fr') 😀
- Be on parity with TSC or 1:1, it has some different behaviors **but** should work in existing projects using TSC
- Be on parity with TSC or 1:1, it has some different behaviors **but** should work in existing projects using TSC. [You can see a full comparison of emitted errors and warnings compared with TSC here](https://kaleidawave.github.io/ezno/comparison)
- Faster as a means to serve large codebases. Cut out bloat and complex code first!
- Smarter as a means to allow more *dynamic patterns*. Keep things simple!
- A binary executable compiler. It takes in JavaScript (or a TypeScript or Ezno superset) and does similar processes to traditional compilers, but at the end emits JavaScript. However, in the future, it *could* generate a lower level format using its event (side-effect) representation.
Expand Down
2 changes: 1 addition & 1 deletion checker/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ path-absolutize = { version = "3.0", features = ["use_unix_paths_on_wasm"] }
either = "1.6"
levenshtein = "1"
ordered-float = "4.2"
regress = { version = "0.10.0", features = [] }
regress = { version = "0.10", features = [] }

serde = { version = "1.0", features = ["derive"], optional = true }
simple-json-parser = "0.0.2"
Expand Down
Binary file modified checker/definitions/internal.ts.d.bin
Binary file not shown.
17 changes: 9 additions & 8 deletions checker/definitions/overrides.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ declare class Array<T> {

// TODO this argument
map<U>(cb: (t: T, i?: number) => U): Array<U> {
const { length } = this, mapped: Array<U> = [];
const { length } = this, mapped: U[] = [];
let i: number = 0;
while (i < length) {
const value = this[i];
Expand All @@ -48,7 +48,7 @@ declare class Array<T> {

// // TODO any is debatable
filter(cb: (t: T, i?: number) => any): Array<T> {
const { length } = this, filtered: Array<T> = [];
const { length } = this, filtered: T[] = [];
let i: number = 0;
while (i < length) {
const value = this[i];
Expand Down Expand Up @@ -127,8 +127,9 @@ declare class Array<T> {

type Record<K extends string, T> = { [P in K]: T }

type LessThan<T extends number> = ExclusiveRange<NegativeInfinity, T>;
type GreaterThan<T extends number> = ExclusiveRange<T, Infinity>;
type ExclusiveRange<F extends number, C extends number> = GreaterThan<F> & LessThan<C>;
type InclusiveRange<F extends number, C extends number> = (GreaterThan<F> & LessThan<C>) | (F | C);

type Integer = MultipleOf<1>;

declare class Map<T, U> {
Expand Down Expand Up @@ -202,7 +203,7 @@ declare class Promise<T> { }

declare class RegExp {
@Constant("regexp:constructor")
constructor(pattern: string, flags?: string);
constructor(pattern: string, flags?: string);

@Constant("regexp:exec")
exec(input: string): RegExpExecArray | null;
Expand All @@ -222,10 +223,10 @@ interface RegExpExecArray extends Array<string> {
* The first match. This will always be present because `null` will be returned if there are no matches.
*/
0: string;
}
// }

// es2018
interface RegExpExecArray {
// // es2018
// interface RegExpExecArray {
groups?: {
[key: string]: string;
};
Expand Down
5 changes: 3 additions & 2 deletions checker/definitions/simple.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,9 @@ declare class Map<K, V> {

type Record<K extends string, T> = { [P in K]: T }

type LessThan<T extends number> = ExclusiveRange<NegativeInfinity, T>;
type GreaterThan<T extends number> = ExclusiveRange<T, Infinity>;
type ExclusiveRange<F extends number, C extends Number> = GreaterThan<F> & LessThan<C>;
type InclusiveRange<F extends number, C extends Number> = (GreaterThan<F> & LessThan<C>) | (F | C);

type Integer = MultipleOf<1>;

/**
Expand Down
9 changes: 7 additions & 2 deletions checker/examples/run_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ fn main() {
let no_lib = args.iter().any(|item| item == "--no-lib");
let debug_dts = args.iter().any(|item| item == "--debug-dts");
let extras = args.iter().any(|item| item == "--extras");
let advanced_numbers = args.iter().any(|item| item == "--advanced-numbers");

let now = Instant::now();

Expand All @@ -46,6 +47,7 @@ fn main() {
max_inline_count: 600,
debug_dts,
extra_syntax: extras,
advanced_numbers,
..Default::default()
};

Expand All @@ -60,8 +62,7 @@ fn main() {

if args.iter().any(|arg| arg == "--types") {
eprintln!("Types:");
let types = result.types.into_vec_temp();
for (type_id, item) in &types[types.len().saturating_sub(60)..] {
for (type_id, item) in result.types.user_types() {
eprintln!("\t{type_id:?}: {item:?}");
}
}
Expand All @@ -74,6 +75,10 @@ fn main() {
}
}

if args.iter().any(|arg| arg == "--called-functions") {
eprintln!("Called function: {:?}", result.types.called_functions);
}

if args.iter().any(|arg| arg == "--time") {
let end = now.elapsed();
let count = result.diagnostics.into_iter().len();
Expand Down
6 changes: 4 additions & 2 deletions checker/specification/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ publish = false
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[features]
just-staging = []
default = ["base"]
base = []
staging = []
all = ["staging"]
to_implement = []
all = ["base", "staging", "to_implement"]

[[test]]
name = "specification_test"
Expand Down
4 changes: 2 additions & 2 deletions checker/specification/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let out_path = Path::new(&std::env::var("OUT_DIR")?).join("specification.rs");
let mut out = File::create(out_path)?;

if cfg!(not(feature = "just-staging")) {
if cfg!(feature = "base") {
let specification = read_to_string("./specification.md")?;
markdown_lines_append_test_to_rust(specification.lines().enumerate(), &mut out)?;
}
Expand All @@ -26,7 +26,7 @@ fn main() -> Result<(), Box<dyn Error>> {
writeln!(&mut out, "}}").unwrap();
}

if cfg!(feature = "all") {
if cfg!(feature = "to_implement") {
let to_implement = read_to_string("./to_implement.md")?;
writeln!(&mut out, "mod to_implement {{ ").unwrap();
writeln!(&mut out, "use super::{{check_expected_diagnostics, TypeCheckOptions}}; ")
Expand Down
Loading

0 comments on commit dab8faf

Please sign in to comment.