Skip to content

fix(vscode-ext): pass real callbacks to registerCommand (affinescript#35 P2)#60

Merged
hyperpolymath merged 1 commit into
mainfrom
fix/vscode-ext-affine-registercommand
May 18, 2026
Merged

fix(vscode-ext): pass real callbacks to registerCommand (affinescript#35 P2)#60
hyperpolymath merged 1 commit into
mainfrom
fix/vscode-ext-affine-registercommand

Conversation

@hyperpolymath
Copy link
Copy Markdown
Owner

The VS Code extension now compiles. Root cause was not the affinescript toolchain or upstream stdlib (those type-check fine on affinescript origin/main) — it was my-lang's own src/extension.affine using a stale Phase-1 contract.

Bug

registerCommand("my-lang.run", 0) passed an Int "wasm-table index", but the Phase-2 (#35) binding is:

pub extern fn registerCommand(name: String, handler: fn(Unit) -> Int) -> Disposable;

Unify.TypeMismatch ((Unit -> Int), Int); the extension would not build at all.

Fix

Handlers passed as real callbacks, mirroring affinescript's own examples/vscode_extension_minimal.affine:
registerCommand("my-lang.run", fn(u: Unit) => handler_run()) (×3); obsolete index comment replaced.

Verification

  • affinescript compile --vscode-extension src/extension.affine -o out/extension.cjssucceeds (tested against affinescript origin/main stdlib in an isolated worktree; the live affinescript clone was never touched).
  • Regenerated out/extension.cjs passes node --check; src/index.cjs wires it via require("../out/extension.cjs").
  • No affinescript repo change required — purely the my-lang port.

Builds on #58 (correct --vscode-extension invocation). With this, vsce package produces an installable .vsix (no Azure PAT needed; only vsce publish does).

Refs affinescript#35
Refs affinescript#64

🤖 Generated with Claude Code

…#35 P2)

src/extension.affine called registerCommand("my-lang.run", 0) with an
Int "wasm-table index" — a Phase-1 assumption. The Phase-2 (#35) stdlib
binding is `registerCommand(name: String, handler: fn(Unit) -> Int)`, so
the Int literal produced `Unify.TypeMismatch ((Unit -> Int), Int)` and
the extension would not compile at all.

Pass the handlers as real callbacks using the canonical pattern from
affinescript's examples/vscode_extension_minimal.affine:
`registerCommand("my-lang.run", fn(u: Unit) => handler_run())` (×3), and
replace the now-obsolete wasm-table-index comment.

Verified: `affinescript compile --vscode-extension src/extension.affine
-o out/extension.cjs` succeeds (against affinescript origin/main stdlib);
regenerated out/extension.cjs passes `node --check`; src/index.cjs wires
it via require("../out/extension.cjs"). The upstream Vscode stdlib
bindings already type-check on affinescript main — no affinescript change
needed; this was purely the my-lang port using the stale contract.

Refs affinescript#35
Refs affinescript#64

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@hyperpolymath hyperpolymath merged commit b5464ad into main May 18, 2026
10 of 11 checks passed
@hyperpolymath hyperpolymath deleted the fix/vscode-ext-affine-registercommand branch May 18, 2026 10:24
hyperpolymath added a commit that referenced this pull request May 18, 2026
…#61)

`vsce` 2.15.0 (the deprecated package) predates `.cjs`-entrypoint
support, so `vsce package` failed looking for `src/index.cjs.js`.
Migrated devDependency to the renamed, maintained `@vscode/vsce` ^3.2.0
(same `vsce` binary, so the `package` script is unchanged).

Also corrected the README "Status" block, which #58 left stale: the
extension DOES compile and the affinescript Vscode stdlib bindings DO
type-check on affinescript main (#35 P2 effectively complete) — the only
real bug was my-lang's own extension.affine (fixed in #60). Documented
that packaging needs a registry-reachable env (WSL npm is unreachable
here, so package/publish must run on CI or a non-WSL host) and that
`.vsix` packaging needs no Azure PAT (only `vsce publish` does).

Refs affinescript#35

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

🔍 Hypatia Security Scan

Findings: 35 issues detected

Severity Count
🔴 Critical 6
🟠 High 11
🟡 Medium 18

⚠️ Action Required: Critical security issues found!

View findings
[
  {
    "reason": "Issue in quality.yml",
    "type": "missing_workflow",
    "file": "quality.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "Issue in security-policy.yml",
    "type": "missing_workflow",
    "file": "security-policy.yml",
    "action": "create",
    "rule_module": "workflow_audit",
    "severity": "medium"
  },
  {
    "reason": "Action hyperpolymath/standards/.github/workflows/governance-reusable.yml@main needs attention",
    "type": "unpinned_action",
    "file": "governance.yml",
    "action": "pin_sha",
    "rule_module": "workflow_audit",
    "severity": "high"
  },
  {
    "reason": "unwrap_or(0) with dangerous default (1 occurrences, CWE-754)",
    "type": "unwrap_dangerous_default",
    "file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "critical"
  },
  {
    "reason": "expect() in hot path (80 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/my-lang/my-lang/_exploratory/me-scaffolding/crates/parser/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
    "type": "unwrap_without_check",
    "file": "/home/runner/work/my-lang/my-lang/my-ssg/src/generator.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "expect() in hot path (5 occurrences, CWE-754)",
    "type": "expect_in_hot_path",
    "file": "/home/runner/work/my-lang/my-lang/crates/my-mir/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "medium"
  },
  {
    "reason": "unwrap() without prior check -- DoS via panic (26 occurrences, CWE-754)",
    "type": "unwrap_without_check",
    "file": "/home/runner/work/my-lang/my-lang/crates/my-fmt/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "unwrap() without prior check -- DoS via panic (1 occurrences, CWE-754)",
    "type": "unwrap_without_check",
    "file": "/home/runner/work/my-lang/my-lang/crates/my-hir/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  },
  {
    "reason": "unwrap() without prior check -- DoS via panic (3 occurrences, CWE-754)",
    "type": "unwrap_without_check",
    "file": "/home/runner/work/my-lang/my-lang/crates/my-llvm/src/lib.rs",
    "action": "flag",
    "rule_module": "code_safety",
    "severity": "high"
  }
]

Powered by Hypatia Neurosymbolic CI/CD Intelligence

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant