arc-lang 0.6.13 → 0.6.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -236,13 +236,15 @@ function makePrelude(env) {
236
236
  return null;
237
237
  },
238
238
  len: (v) => {
239
+ if (v === undefined || v === null)
240
+ throw new Error("len() requires an argument — pass a string, list, or map");
239
241
  if (typeof v === "string")
240
242
  return [...v].length; // codepoint count, not UTF-16
241
243
  if (Array.isArray(v))
242
244
  return v.length;
243
245
  if (v && typeof v === "object" && "__map" in v)
244
246
  return v.entries.size;
245
- return 0;
247
+ throw new Error("len() expects a string, list, or map — got " + typeof v);
246
248
  },
247
249
  map: (list, fn) => {
248
250
  if (!Array.isArray(list))
@@ -2792,10 +2794,14 @@ function evalExpr(expr, env) {
2792
2794
  if (idx !== Math.floor(idx))
2793
2795
  throw new ArcRuntimeError("String index must be an integer");
2794
2796
  let i = idx < 0 ? obj.length + idx : idx;
2795
- return i >= 0 && i < obj.length ? obj.charAt(i) : null;
2797
+ if (i < 0 || i >= obj.length)
2798
+ throw new ArcRuntimeError(`String index out of bounds: index ${idx} but length is ${obj.length}`);
2799
+ return obj.charAt(i);
2796
2800
  }
2797
2801
  if (Array.isArray(obj) && typeof idx === "number") {
2798
2802
  let i = idx < 0 ? obj.length + idx : idx;
2803
+ if (i < 0 || i >= obj.length)
2804
+ throw new ArcRuntimeError(`Index out of bounds: index ${idx} but length is ${obj.length}`);
2799
2805
  return obj[i] ?? null;
2800
2806
  }
2801
2807
  if (obj && typeof obj === "object" && "__map" in obj) {
package/dist/version.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const ARC_VERSION = "0.6.13";
1
+ export declare const ARC_VERSION = "0.6.14";
2
2
  export declare const ARC_BUILD_DATE: string;
3
3
  export declare const ARC_PLATFORM: string;
4
4
  /** Print version info */
package/dist/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // Arc Version System
2
- export const ARC_VERSION = "0.6.13";
2
+ export const ARC_VERSION = "0.6.14";
3
3
  export const ARC_BUILD_DATE = new Date().toISOString().split("T")[0];
4
4
  export const ARC_PLATFORM = `${process.platform}-${process.arch}`;
5
5
  /** Print version info */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arc-lang",
3
- "version": "0.6.13",
3
+ "version": "0.6.14",
4
4
  "description": "Arc ⚡ — A programming language designed by AI agents, for AI agents. 27-63% fewer tokens than JavaScript.",
5
5
  "type": "module",
6
6
  "bin": {