docs for cli fix; KMP compatibility bug fix

This commit is contained in:
Sergey Chernov 2026-04-08 22:54:22 +03:00
parent ef95ed4405
commit aa1b74620e
3 changed files with 13 additions and 11 deletions

View File

@ -18,6 +18,7 @@
- Avoid creating suspend lambdas for compiler runtime statements. Prefer explicit `object : Statement()` with `override suspend fun execute(...)`.
- Do not use `statement { ... }` or other inline suspend lambdas in compiler hot paths (e.g., parsing/var declarations, initializer thunks).
- If you need a wrapper for delegated properties, check for `getValue` explicitly and return a concrete `Statement` object when missing; avoid `onNotFoundResult` lambdas.
- For any code in `commonMain`, verify it is Kotlin Multiplatform compatible before finishing. Do not use JVM-only APIs or Java-backed convenience methods such as `Map.putIfAbsent`; prefer stdlib/common equivalents and run at least the relevant compile/test task that exercises the `commonMain` source set.
- If wasmJs browser tests hang, first run `:lynglib:wasmJsNodeTest` and look for wasm compilation errors; hangs usually mean module instantiation failed.
- Do not increase test timeouts to mask wasm generation errors; fix the invalid IR instead.

View File

@ -1,4 +1,4 @@
### Lyng CLI (`lyng`)
# Lyng CLI (`lyng`)
The Lyng CLI is the reference command-line tool for the Lyng language. It lets you:
@ -8,7 +8,7 @@ The Lyng CLI is the reference command-line tool for the Lyng language. It lets y
- Format Lyng source files via the built-in `fmt` subcommand.
#### Building on Linux
## Building on Linux
Requirements:
- JDK 17+ (for Gradle and the JVM distribution)
@ -20,7 +20,7 @@ The repository provides convenience scripts in `bin/` for local builds and insta
Note: In this repository the scripts are named `bin/local_release` and `bin/local_jrelease`. In some environments these may be aliased as `bin/release` and `bin/jrelease`. The steps below use the actual file names present here.
##### Option A: Native linuxX64 executable (`lyng`)
### Option A: Native linuxX64 executable (`lyng`)
1) Build the native binary:
@ -39,7 +39,7 @@ What this does:
- Produces `distributables/lyng-linuxX64.zip` containing the `lyng` executable.
##### Option B: JVM distribution (`jlyng` launcher)
### Option B: JVM distribution (`jlyng` launcher)
This creates a JVM distribution with a launcher script, packages it as a downloadable zip, and links it to `~/bin/jlyng`.
@ -54,12 +54,12 @@ What this does:
- Creates a symlink `~/bin/jlyng` pointing to the launcher script.
#### Usage
## Usage
Once installed, ensure `~/bin` is on your `PATH`. You can then use either the native `lyng` or the JVM `jlyng` launcher (both have the same CLI surface).
##### Running scripts
### Running scripts
- Run a script by file name and pass arguments to `ARGV`:
@ -87,7 +87,7 @@ lyng --version
lyng --help
```
##### Local imports for file execution
### Local imports for file execution
When you execute a script file, the CLI builds a temporary local import manager rooted at the directory that contains the entry script.
@ -144,7 +144,7 @@ Rationale:
- Explicit `package` remains available as a consistency check instead of a second, conflicting naming system.
- The import search space stays local to the executed script, which avoids accidental cross-project resolution.
### Use in shell scripts
## Use in shell scripts
Standard unix shebangs (`#!`) are supported, so you can make Lyng scripts directly executable on Unix-like systems. For example:
@ -152,7 +152,7 @@ Standard unix shebangs (`#!`) are supported, so you can make Lyng scripts direct
println("Hello, world!")
##### Formatting source: `fmt` subcommand
### Formatting source: `fmt` subcommand
Format Lyng files with the built-in formatter.
@ -194,7 +194,7 @@ lyng fmt --spacing --wrap src/file.lyng
```
#### Notes
## Notes
- Both native and JVM distributions expose the same CLI interface. Use whichever best fits your environment.
- When executing scripts, all positional arguments after the script name are available in Lyng as `ARGV`.

View File

@ -195,13 +195,14 @@ private fun discoverLocalCliModules(entryFile: Path): List<LocalCliModule> {
)
}
val packageName = declaredPackage ?: expectedPackage
val previous = seenPackages.putIfAbsent(packageName, file)
val previous = seenPackages[packageName]
if (previous != null) {
throw ScriptError(
source.startPos,
"duplicate local module '$packageName': ${previous.toString()} and ${file.toString()}"
)
}
seenPackages[packageName] = file
LocalCliModule(packageName, source)
}
.toList()