diff --git a/nix-js/runtime-ts/src/builtins/attrs.ts b/nix-js/runtime-ts/src/builtins/attrs.ts index e0be552..4484b45 100644 --- a/nix-js/runtime-ts/src/builtins/attrs.ts +++ b/nix-js/runtime-ts/src/builtins/attrs.ts @@ -31,6 +31,7 @@ export const hasAttr = (set: NixValue): boolean => Object.hasOwn(forceAttrs(set), forceStringValue(s)); +let counter = 0; export const mapAttrs = (f: NixValue) => (attrs: NixValue): NixAttrs => { @@ -38,7 +39,8 @@ export const mapAttrs = const forcedF = forceFunction(f); const newAttrs: NixAttrs = {}; for (const key in forcedAttrs) { - newAttrs[key] = createThunk(() => forceFunction(forcedF(key))(forcedAttrs[key])); + newAttrs[key] = createThunk(() => forceFunction(forcedF(key))(forcedAttrs[key]), `created by mapAttrs (${counter})`); + counter += 1; } return newAttrs; }; diff --git a/nix-js/runtime-ts/src/builtins/index.ts b/nix-js/runtime-ts/src/builtins/index.ts index f369d43..3da9bb9 100644 --- a/nix-js/runtime-ts/src/builtins/index.ts +++ b/nix-js/runtime-ts/src/builtins/index.ts @@ -249,11 +249,11 @@ export const builtins: any = { tryEval: mkPrimop(misc.tryEval, "tryEval", 1), zipAttrsWith: mkPrimop(misc.zipAttrsWith, "zipAttrsWith", 2), - builtins: createThunk(() => builtins), + builtins: createThunk(() => builtins, "builtins"), currentSystem: createThunk(() => { return "x86_64-linux"; - }), - currentTime: createThunk(() => Date.now()), + }, "currentSystem"), + currentTime: createThunk(() => Date.now(), "currentTime"), false: false, true: true, diff --git a/nix-js/runtime-ts/src/builtins/misc.ts b/nix-js/runtime-ts/src/builtins/misc.ts index 2e92601..adda38d 100644 --- a/nix-js/runtime-ts/src/builtins/misc.ts +++ b/nix-js/runtime-ts/src/builtins/misc.ts @@ -7,7 +7,7 @@ import { CatchableError } from "../types"; import type { NixAttrs, NixBool, NixStrictValue, NixValue } from "../types"; import { forceList, forceAttrs, forceFunction, forceStringValue, forceString } from "../type-assert"; import * as context from "./context"; -import { compareValues, op } from "../operators"; +import { compareValues } from "../operators"; import { isBool, isFloat, isInt, isList, isString, typeOf } from "./type-check"; import { OrderedSet } from "js-sdsl"; import { @@ -15,13 +15,13 @@ import { getStringValue, getStringContext, mkStringWithContext, - mergeContexts, } from "../string-context"; export const addErrorContext = (e1: NixValue) => - (e2: NixValue): never => { - throw new Error("Not implemented: addErrorContext"); + (e2: NixValue): NixValue => { + console.log("[WARNING]: addErrorContext not implemented"); + return e2; }; export const appendContext = context.appendContext; diff --git a/nix-js/runtime-ts/src/types.ts b/nix-js/runtime-ts/src/types.ts index b6bf0ec..6537288 100644 --- a/nix-js/runtime-ts/src/types.ts +++ b/nix-js/runtime-ts/src/types.ts @@ -62,11 +62,16 @@ export class NixArgs { } } } -export const mkFunction = (f: (arg: NixValue) => NixValue, required: string[], optional: string[], ellipsis: boolean): NixFunction => { +export const mkFunction = ( + f: (arg: NixValue) => NixValue, + required: string[], + optional: string[], + ellipsis: boolean, +): NixFunction => { const func = f as NixFunction; func.args = new NixArgs(required, optional, ellipsis); - return func -} + return func; +}; /** * Interface for lazy thunk values diff --git a/nix-js/src/context.rs b/nix-js/src/context.rs index 0bba013..f00d4eb 100644 --- a/nix-js/src/context.rs +++ b/nix-js/src/context.rs @@ -47,9 +47,6 @@ mod private { fn compile_code(&mut self, source: Source) -> Result { self.as_mut().compile_code(source) } - fn get_current_source(&self) -> Source { - self.as_ref().get_current_source() - } fn get_source(&self, id: usize) -> Source { self.as_ref().get_source(id) } diff --git a/nix-js/src/error.rs b/nix-js/src/error.rs index 0060705..2f36a3a 100644 --- a/nix-js/src/error.rs +++ b/nix-js/src/error.rs @@ -1,11 +1,12 @@ +#![allow(unused_assignments)] + +use std::path::{Path, PathBuf}; +use std::sync::Arc; + use miette::{Diagnostic, NamedSource, SourceSpan}; -use std::{ - path::{Path, PathBuf}, - sync::Arc, -}; use thiserror::Error; -use crate::{context::Ctx, runtime::RuntimeContext}; +use crate::runtime::RuntimeContext; pub type Result = core::result::Result>; diff --git a/nix-js/src/fetcher/metadata_cache.rs b/nix-js/src/fetcher/metadata_cache.rs index 9eb70ad..39180aa 100644 --- a/nix-js/src/fetcher/metadata_cache.rs +++ b/nix-js/src/fetcher/metadata_cache.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + use rusqlite::{Connection, OptionalExtension, params}; use serde::{Deserialize, Serialize}; use std::path::PathBuf; diff --git a/nix-js/src/ir.rs b/nix-js/src/ir.rs index 9f021b2..a0f8645 100644 --- a/nix-js/src/ir.rs +++ b/nix-js/src/ir.rs @@ -1,5 +1,5 @@ use derive_more::{IsVariant, TryUnwrap, Unwrap}; -use hashbrown::{HashMap, HashSet}; +use hashbrown::HashMap; use rnix::{TextRange, ast}; use string_interner::symbol::SymbolU32; diff --git a/nix-js/src/ir/downgrade.rs b/nix-js/src/ir/downgrade.rs index 160c4ad..f0542c4 100644 --- a/nix-js/src/ir/downgrade.rs +++ b/nix-js/src/ir/downgrade.rs @@ -401,7 +401,6 @@ impl Downgrade for ast::Lambda { pat_entries, alias, arg, - ellipsis, ctx, |ctx, _| self.body().unwrap().downgrade(ctx), )?; diff --git a/nix-js/src/ir/span_utils.rs b/nix-js/src/ir/span_utils.rs index bcf1c67..4442faa 100644 --- a/nix-js/src/ir/span_utils.rs +++ b/nix-js/src/ir/span_utils.rs @@ -1,3 +1,5 @@ +#![allow(unused)] + use rnix::TextRange; pub fn merge_spans(spans: impl IntoIterator) -> TextRange { @@ -11,10 +13,6 @@ pub fn merge_spans(spans: impl IntoIterator) -> TextRange { }) } -pub fn point_span() -> TextRange { - TextRange::new(0.into(), 0.into()) -} - pub fn synthetic_span() -> TextRange { TextRange::new(0.into(), 0.into()) } diff --git a/nix-js/src/ir/utils.rs b/nix-js/src/ir/utils.rs index 5d9e150..f0e6c51 100644 --- a/nix-js/src/ir/utils.rs +++ b/nix-js/src/ir/utils.rs @@ -225,7 +225,6 @@ pub fn downgrade_pattern_bindings( pat_entries: impl Iterator, alias: Option, arg: ExprId, - has_ellipsis: bool, ctx: &mut Ctx, body_fn: impl FnOnce(&mut Ctx, &[SymId]) -> Result, ) -> Result diff --git a/nix-js/src/runtime.rs b/nix-js/src/runtime.rs index 6b39bb1..eb367d4 100644 --- a/nix-js/src/runtime.rs +++ b/nix-js/src/runtime.rs @@ -18,7 +18,6 @@ pub(crate) trait RuntimeContext: 'static { fn get_current_dir(&self) -> &Path; fn add_source(&mut self, path: Source); fn compile_code(&mut self, source: Source) -> Result; - fn get_current_source(&self) -> Source; fn get_source(&self, id: usize) -> Source; } diff --git a/nix-js/src/store.rs b/nix-js/src/store.rs index 4e78f7f..3b90899 100644 --- a/nix-js/src/store.rs +++ b/nix-js/src/store.rs @@ -1,3 +1,5 @@ +#![allow(dead_code)] + mod config; mod error; mod validation;