diff --git a/kmath-ast/src/jsMain/kotlin/kscience/kmath/estree/internal/ESTreeBuilder.kt b/kmath-ast/src/jsMain/kotlin/kscience/kmath/estree/internal/ESTreeBuilder.kt index e58ad54b3..349686b83 100644 --- a/kmath-ast/src/jsMain/kotlin/kscience/kmath/estree/internal/ESTreeBuilder.kt +++ b/kmath-ast/src/jsMain/kotlin/kscience/kmath/estree/internal/ESTreeBuilder.kt @@ -40,9 +40,10 @@ internal class ESTreeBuilder(val bodyCallback: ESTreeBuilder.() -> BaseExp private val keys = mutableListOf() fun constant(value: Any?) = when { - value == null || jsTypeOf(value) == "number" || jsTypeOf(value) == "string" || jsTypeOf(value) == "boolean" -> { + value == null || jsTypeOf(value) == "number" || jsTypeOf(value) == "string" || jsTypeOf(value) == "boolean" -> SimpleLiteral(value) - } + + jsType(value) == "undefined" -> Identifier("undefined") else -> { val idx = if (value in constants) constants.indexOf(value) else constants.also { it += value }.lastIndex