Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: check

on:
push:
branches:
- master
- main
pull_request:

jobs:
check:
strategy:
fail-fast: false
runs-on: ubuntu-latest
continue-on-error: false
steps:
- uses: actions/checkout@v4
with:
submodules: 'recursive'

- name: install
run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> $GITHUB_PATH

- name: moon version
run: |
moon version --all

- name: moon check
run: |
moon update
moon check --deny-warn

- name: moon info
run: |
moon info --target all
git diff --exit-code

- name: format diff
run: |
moon fmt
git diff --exit-code

- name: moon test
run: |
moon test --target all
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
.mooncakes/
.mooncakes/
_build/
38 changes: 38 additions & 0 deletions codex_report.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Dependency Error Report

## Dependency

`peter-jerry-ye/io@0.3.4`

## Command

```bash
moon check
```

## Error

`moon check` fails while calculating the build plan:

```text
Error: Failed to calculate build plan

Caused by:
0: Failed to solve package relationship
1: Import tonyfettes/encoding@0.3.7 exists in global environment,
but its containing module is not imported by peter-jerry-ye/io@0.3.4, thus cannot be imported by its package 'http'
```

## Attempted Fix

Ran:

```bash
moon add peter-jerry-ye/io
```

The command completed, but did not update `moon.mod.json` or any other tracked repository file. Running `moon check` afterwards produced the same dependency resolution error.

## Conclusion

The failure comes from `peter-jerry-ye/io@0.3.4`: its `http` package imports `tonyfettes/encoding@0.3.7`, but that containing module is not declared by `peter-jerry-ye/io@0.3.4`. This needs to be fixed in the dependency or by moving this repository to a dependency version where that relationship is declared correctly.
9 changes: 4 additions & 5 deletions moon.mod.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
{
"name": "moonbit-community/cli-template",
"deps": {
"peter-jerry-ye/wasi-imports": "0.1.3",
"peter-jerry-ye/io": "0.3.4",
"peter-jerry-ye/async": "0.2.0"
"peter-jerry-ye/wasi-imports": "0.1.5"
},
"source": "src"
}
"source": "src",
"preferred-target": "wasm"
}
19 changes: 19 additions & 0 deletions src/moon.pkg
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {
"peter-jerry-ye/wasi-imports/ffi" @ffi,
"peter-jerry-ye/wasi-imports/interface/wasi/cli/stdout" @stdout,
"peter-jerry-ye/wasi-imports/interface/wasi/io/streams",
}

options(
link: {
"wasm": {
"export-memory-name": "memory",
"exports": [
"cabi_realloc:cabi_realloc",
"wasmExportRun:wasi:cli/run@0.2.0#run",
],
"heap-start-address": 16,
},
},
supported_targets: [ "wasm" ],
)
21 changes: 0 additions & 21 deletions src/moon.pkg.json

This file was deleted.

18 changes: 18 additions & 0 deletions src/pkg.generated.mbti
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Generated using `moon info`, DON'T EDIT IT
package "moonbit-community/cli-template"

// Values
pub fn cabi_realloc(Int, Int, Int, Int) -> Int

pub fn run() -> Result[Unit, Unit]

pub fn wasmExportRun() -> Int

// Errors

// Types and methods

// Type aliases

// Traits

25 changes: 11 additions & 14 deletions src/stub.mbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
///|
/// Run the program.
pub fn run() -> Result[Unit, Unit] {
let mut result = Ok(())
@promise.spawn(async fn() {
top() catch {
error => {
result = Err(())
@io.println_sync("Error \{error}", stream=@io.stderr)
}
}
})
|> ignore
@io.event_loop.run()
result
top()
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Catch raised errors in run before returning status

run() now returns top() directly, which removes the previous catch boundary that translated unexpected runtime errors into Err(()). If a user-modified top raises (or otherwise traps) instead of returning Err, the exported wasi:cli/run path will abort the component rather than returning an error status, changing failure behavior for hosts that expect a normal result-based exit.

Useful? React with 👍 / 👎.

}

///|
/// User should change this function to do what they want
async fn top() -> Unit {
@io.println("Hello, world!")
fn top() -> Result[Unit, Unit] {
let stdout = @stdout.get_stdout()
let result = stdout.blocking_write_and_flush(
b"Hello, world!\n".to_fixedarray(),
)
stdout.drop()
match result {
Ok(_) => Ok(())
Err(_) => Err(())
}
}
Loading