arc-lang 0.6.12 → 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.
@@ -27,6 +27,13 @@ class Env {
27
27
  suggestion: "Did you mean 'let mut' to declare a mutable variable?",
28
28
  });
29
29
  }
30
+ if (name === "import") {
31
+ throw new ArcRuntimeError(`Undefined variable: ${name}`, {
32
+ code: ErrorCode.UNDEFINED_VARIABLE,
33
+ category: "RuntimeError",
34
+ suggestion: "Arc uses 'use' instead of 'import'. Try: use modulename",
35
+ });
36
+ }
30
37
  const candidates = this.allNames();
31
38
  const closest = findClosestMatch(name, candidates);
32
39
  throw new ArcRuntimeError(`Undefined variable: ${name}`, {
@@ -229,13 +236,15 @@ function makePrelude(env) {
229
236
  return null;
230
237
  },
231
238
  len: (v) => {
239
+ if (v === undefined || v === null)
240
+ throw new Error("len() requires an argument — pass a string, list, or map");
232
241
  if (typeof v === "string")
233
242
  return [...v].length; // codepoint count, not UTF-16
234
243
  if (Array.isArray(v))
235
244
  return v.length;
236
245
  if (v && typeof v === "object" && "__map" in v)
237
246
  return v.entries.size;
238
- return 0;
247
+ throw new Error("len() expects a string, list, or map — got " + typeof v);
239
248
  },
240
249
  map: (list, fn) => {
241
250
  if (!Array.isArray(list))
@@ -2785,10 +2794,14 @@ function evalExpr(expr, env) {
2785
2794
  if (idx !== Math.floor(idx))
2786
2795
  throw new ArcRuntimeError("String index must be an integer");
2787
2796
  let i = idx < 0 ? obj.length + idx : idx;
2788
- 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);
2789
2800
  }
2790
2801
  if (Array.isArray(obj) && typeof idx === "number") {
2791
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}`);
2792
2805
  return obj[i] ?? null;
2793
2806
  }
2794
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.9";
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.9";
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.12",
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": {
package/stdlib/MODULES.md CHANGED
@@ -781,21 +781,17 @@ stdlib/
781
781
  └── cmd/ # Command execution
782
782
  ```
783
783
 
784
- ### Import Syntax
784
+ ### Use Syntax
785
785
 
786
786
  ```arc
787
- // Import entire module
788
- import collections
787
+ // Use entire module
788
+ use collections
789
789
 
790
- // Import specific exports
791
- import {List, Map, Set} from collections
790
+ // Use specific exports
791
+ use collections { List, Map, Set }
792
792
 
793
- // Import with alias
794
- import collections as col
795
- import {List as L} from collections
796
-
797
- // Import everything (discouraged)
798
- import * from collections
793
+ // Use everything (discouraged)
794
+ use collections { * }
799
795
  ```
800
796
 
801
797
  ---
package/stdlib/README.md CHANGED
@@ -40,7 +40,7 @@ strings.capitalize("hello") # => "Hello"
40
40
  strings.words("one two three") # => ["one", "two", "three"]
41
41
  ```
42
42
 
43
- ## Built-in Functions (No Import)
43
+ ## Built-in Functions (No `use` Required)
44
44
 
45
45
  Many common operations are built into Arc and need no `use` statement:
46
46