Skip to content

Commit 0771e42

Browse files
committed
chore: circular dependency issue
1 parent 5d3df6e commit 0771e42

2 files changed

Lines changed: 13 additions & 4 deletions

File tree

src/compute-engine/boxed-expression/abstract-boxed-expression.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ import type {
3131

3232
import type { NumericValue } from '../numeric-value/types';
3333
import type { SmallInteger } from '../numerics/types';
34-
// Dynamic import for JavaScriptTarget to avoid circular dependency
35-
import { applicableN1 } from '../function-utils';
34+
// Dynamic import for JavaScriptTarget and applicableN1 to avoid circular dependency
3635

3736
import {
3837
getApplyFunctionStyle,
@@ -773,7 +772,11 @@ export abstract class _BoxedExpression implements BoxedExpression {
773772
});
774773
} catch (e) {
775774
// @fixme: the fallback needs to handle multiple arguments
776-
if (options?.fallback ?? true) return applicableN1(this);
775+
if (options?.fallback ?? true) {
776+
// Dynamic import to avoid circular dependency
777+
const { applicableN1 } = require('../function-utils');
778+
return applicableN1(this);
779+
}
777780
throw e;
778781
}
779782
}

src/compute-engine/boxed-expression/compare.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NumericValue } from '../numeric-value/types';
22
import type { BoxedExpression } from '../global-types';
33
import { AbstractTensor } from '../tensor/tensors';
4-
import { getInequalityBoundsFromAssumptions } from '../assume';
4+
// Dynamic import to avoid circular dependency
55

66
/**
77
* Structural equality of boxed expressions.
@@ -201,6 +201,8 @@ export function cmp(
201201
if (!b.isNumberLiteral) {
202202
// Check if b is a symbol with inequality assumptions
203203
if (b.symbol) {
204+
// Dynamic import to avoid circular dependency
205+
const { getInequalityBoundsFromAssumptions } = require('../assume');
204206
const bounds = getInequalityBoundsFromAssumptions(a.engine, b.symbol);
205207
const aNum =
206208
typeof a.numericValue === 'number'
@@ -262,6 +264,8 @@ export function cmp(
262264
if (typeof b === 'number') {
263265
// Check if a is a symbol with inequality assumptions
264266
if (a.symbol) {
267+
// Dynamic import to avoid circular dependency
268+
const { getInequalityBoundsFromAssumptions } = require('../assume');
265269
const bounds = getInequalityBoundsFromAssumptions(a.engine, a.symbol);
266270

267271
// We're comparing a (symbol) to b (number)
@@ -348,6 +352,8 @@ export function cmp(
348352

349353
// Check inequality assumptions for the symbol
350354
if (b.isNumberLiteral) {
355+
// Dynamic import to avoid circular dependency
356+
const { getInequalityBoundsFromAssumptions } = require('../assume');
351357
const bounds = getInequalityBoundsFromAssumptions(a.engine, a.symbol);
352358
const bNum =
353359
typeof b.numericValue === 'number'

0 commit comments

Comments
 (0)