---
title: Limitations
description: >-
  Current constraints and known limitations in kScript. Many of these will be
  addressed in future updates.
---

<div class="flex gap-3 mb-6">
  <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-yellow-50 text-yellow-600 text-sm font-medium">
    FAQ
  </span>
  <span class="inline-flex items-center gap-1.5 px-3 py-1 rounded-full bg-gray-100 text-gray-600 text-sm font-medium">
    4 min read
  </span>
</div>

## Syntax Limitations

Current restrictions in kScript syntax and expression support.

### No Block Comments

kScript currently only supports single-line comments using `//`. Multi-line block comments with `/* */` are not yet supported.

**Workaround:** Use multiple single-line comments for longer explanations.

```javascript title="Block Comments" lines wrap
// ❌ Block comments are not supported
/* This will cause an error */

// ✓ Use single-line comments instead
// This is a single-line comment
// You can use multiple lines
// To create longer comments
// Like this
```

### Single Quotes Not Allowed

String literals must use double quotes (`"`). Single quotes (`'`) are not supported and will cause syntax errors.

**Solution:** Always use double quotes for strings and basically everything.

```javascript title="Double Quotes for Strings" lines wrap
// ❌ Single quotes are not allowed
var myString = 'This will cause an error';

// ✓ Use double quotes instead
var myString = "This works correctly";
```

### No Mixed Keyword and Positional Arguments

Function calls must use either all keyword arguments or all positional arguments. Mixing both styles in the same function call is not supported and will cause errors.

**Solution:** Choose one style and use it consistently throughout the function call.

```javascript title="Keyword vs Positional Arguments" lines wrap
// ❌ Mixing keyword and positional arguments
plotLine(combinedData, colors=[splineColors, "transparent"], width=width, fill, smooth);

// ✓ Use all keyword arguments
plotLine(value=combinedData, width=width, colors=[splineColors, "transparent"], fill=fill, smooth=smooth, label=["Data"], desc=["Combined Data"]);

// ✓ Or use all positional arguments
plotLine(combinedData, [splineColors, "transparent"], width, fill, smooth);
```

### Only 'var' for Variable Declaration

kScript only supports the `var` keyword for variable declarations. Modern JavaScript keywords like `let` and `const` are not supported.

**Solution:** Use `var` for all variable declarations, `timeseries` for time series data sources.

```javascript title="Variable Declarations" lines wrap
// ❌ let and const are not supported
let myValue = 100;
const PI = 3.14159;

// ✓ Use var instead
var myValue = 100;
var PI = 3.14159;
```

## Feature Limitations

Language features that are currently not available or have restrictions.

### No Module/Import System

kScript does not support importing code from other files. All code must be written in a single file.

**Workaround:** Copy-paste shared functions or use string concatenation for reusable code.

```javascript title="No Imports" lines wrap
// ❌ Module imports are not supported
import { myFunction } from "./utils.kscript"
import { calculateSMA } from "./indicators.kscript"

// ✓ All code must be in a single file
// Copy shared functions directly into your script
```

### No Switch/Case Statement

kScript only supports `if/else` conditionals. The `switch/case` statement is not available.

**Solution:** Use multiple if-else statements or ternary operators.

```javascript title="Switch/Case Workaround" lines wrap
// ❌ Switch/case statements are not supported
switch (signal_type) {
    case "buy":
        action = "long"
        break
    case "sell":
        action = "short"
        break
}

// ✓ Use if-else statements instead
if (signal_type == "buy") {
    var action = "long"
} else if (signal_type == "sell") {
    var action = "short"
} else {
    var action = "hold"
}
```

### No Default Parameters

Function parameters cannot have default values. All parameters must be provided when calling the function.

**Workaround:** Use null checking and assign defaults in the function body, or use the `input()` function for user-configurable defaults.

```javascript title="Default Parameter Workaround" lines wrap
// ❌ Default parameters are not supported
func calculateSMA(source, period = 14) {
    return sma(source, period)
}

// ✓ Handle defaults in the function body
func calculateSMA(source, period) {
    var actualPeriod = period != na ? period : 14
    return sma(source, actualPeriod)
}

// ✓ Or use input() for user-configurable defaults
var defaultPeriod = input("Period", "number", defaultValue=14)
```

### No Rest/Spread Parameters

Functions must have a fixed number of parameters. Variable-length argument lists (rest parameters) are not supported.

**Workaround:** Use arrays to pass multiple values, or define separate functions for different parameter counts.

```javascript title="Rest/Spread Parameter Workaround" lines wrap
// ❌ Rest/spread parameters are not supported
func sum(...numbers) {
    var total = 0
    for (var i = 0; i < numbers.length; i++) {
        total = total + numbers[i]
    }
    return total
}

// ✓ Use an array parameter instead
func sum(numbers) {
    var total = 0
    for (var i = 0; i < numbers.length; i++) {
        total = total + numbers[i]
    }
    return total
}

// Call with an array
var result = sum([1, 2, 3, 4, 5])
```

### Limited Data Types

kScript has a restricted set of data types compared to general-purpose programming languages. Supported types include numbers, strings, booleans, and timeseries.

{% hint style="info" %}
**Supported Types**

`number`, `string`, `boolean`, `timeseries`, `array` (v2.0)
{% endhint %}

### Limited Built-in Functions

kScript is still expanding its standard library. Some functions available in other scripting languages may not yet be available.

Check the [kScript Reference](/kscript/reference/quick-reference) for available functions, or request new features in [**#kscript-floor**](https://discord.gg/hjQRzQtbNu).

## Data Processing Limitations

Constraints when working with historical and timeseries data.

### Limited Historical Data Access

Historical data availability depends on the data source. Accessing data too far back may return `NaN` or undefined values.

**Best Practice:** Always check for `NaN` values and validate `barIndex` before accessing historical data.

```javascript title="Historical Data Access" lines wrap
// ❌ May return NaN if accessing too far back
var very_old_price = price_data.close[1000]

// ✓ Check barIndex and validate data
var safe_value = barIndex >= 10 ? price_data.close[10] : na

// ✓ Always check for NaN values
if (!isnan(price_data.close[5]) && barIndex >= 5) {
    var historical_value = price_data.close[5]
    // Use historical_value safely
}
```

## We're Here to Help

Encountered a limitation not listed here? Have a feature request?

Report bugs and share feedback in [**bugs-kscript**](https://discord.gg/Bj3ynap3S7) or reach out to the development team. Your input helps us prioritize improvements!
