writing-omega: literal-only operations and retyped names (errors 11, 7)
open94b392d9707943a2 #215 · opened 2026-11-07 07:56 UTC
Imported from GitHub aien-dev/omega-harness#215, by drakestapleton
Base bd107ca15c40b6cdfef0f23afb03a884fe3c8086 · Head b6058688473a49a7d238bcf516e101f34515b9d6
drakestapleton wrote on 2026-11-07 07:56 UTC
Two compiler refusals met while porting the omega-pearl native drivers to Omega (aien-dev/omega-pearl#7), now documented with tested examples.
f add 2 1 to a ulong parameter is error 11: an operation whose values are all bare numbers gets no type from the parameter. f add ulong 2 1 compiles. examples/mistake_literal_op_arg.om.
A name keeps the type of its first assignment: x = g (bool) then x = write ... (long) is error 7. examples/mistake_retype_name.om.
Evidence (EXERCISED): bash examples/gate.sh omc at the skill pin omega-mv f4df8239 (omc 3ad9f10f): GATE PASS examples=112 pass=112 fail=0, both new rows PASS. Positive controls: the corrected forms compile at that pin. Same refusal codes at omega-mv 943d9555 (omc 5f90edea), the omega-pearl PARENT pin.
Lane pearlnative. Needs the usual independent review; not merging my own PR.
Apply it
git checkout -b patch-94b392d9707943a2bd107ca15c40b6cdfef0f23afb03a884fe3c8086
curl -fsSL https://interplane.io/drakestapleton/omega-harness/patches/94b392d9707943a2.patch | git am
diff --git a/examples/mistake_literal_op_arg.expect b/examples/mistake_literal_op_arg.expect
new file mode 100644
index 0000000..9401caf
--- /dev/null
+++ b/examples/mistake_literal_op_arg.expect
@@ -0,0 +1,2 @@
+compile 11
+stderr omc: line 7: error 11
diff --git a/examples/mistake_literal_op_arg.om b/examples/mistake_literal_op_arg.om
new file mode 100644
index 0000000..662b2f3
--- /dev/null
+++ b/examples/mistake_literal_op_arg.om
@@ -0,0 +1,9 @@
+note mistake_literal_op_arg: an operation whose values are all bare numbers has no type, even as the
+note argument of a typed parameter. Fix: type one value, f add ulong 2 1
+fn f q ulong to ulong
+ret q
+end
+fn main to int
+r = f add 2 1
+ret int r
+end
diff --git a/examples/mistake_retype_name.expect b/examples/mistake_retype_name.expect
new file mode 100644
index 0000000..c08f954
--- /dev/null
+++ b/examples/mistake_retype_name.expect
@@ -0,0 +1,2 @@
+compile 7
+stderr omc: line 9: error 7
diff --git a/examples/mistake_retype_name.om b/examples/mistake_retype_name.om
new file mode 100644
index 0000000..b350cbb
--- /dev/null
+++ b/examples/mistake_retype_name.om
@@ -0,0 +1,11 @@
+note mistake_retype_name: a name keeps the type of its first assignment; a later value of another
+note type is refused. Fix: one name per type, b = g then n = write 1 T 0 1
+text T "a"
+fn g to bool
+ret true
+end
+fn main to int
+x = g
+x = write 1 T 0 1
+ret 0
+end
diff --git a/skills/writing-omega/SKILL.md b/skills/writing-omega/SKILL.md
index c0a2356..892474b 100644
--- a/skills/writing-omega/SKILL.md
+++ b/skills/writing-omega/SKILL.md
@@ -125,7 +125,12 @@ Every declaration and statement form at the pin (OMEGESE sections 9 to 12 are th
type word: `long x`, `uint b`, `f64 n`.
- **A bare number takes its type from context**: the other value of its operation, the parameter it
is passed to, the result type at `ret`. With no context it is error 11: write `x = uint 5`, never
- `x = 5` for a new name.
+ `x = 5` for a new name. An operation whose values are all bare numbers has no context even as the
+ argument of a typed parameter: `f add 2 1` is error 11, `f add ulong 2 1` compiles
+ (`mistake_literal_op_arg.om`).
+- **A name keeps the type of its first assignment.** Reusing one throwaway name for results of
+ different types (`x = fload ...` a `bool`, then `x = write ...` a `long`) is error 7; use one name
+ per type (`mistake_retype_name.om`).
- Integer literals are decimal with an optional leading `-`. A literal that does not fit its type
is error 8. No character literals: write `uchar 65`, not `'A'` (error 3).
- Float literals need digits on both sides of the dot: `2.0f64`, `1.0e30f64`, `0.5f32`. The suffix is
@@ -367,6 +372,8 @@ Each row is a program in `examples/` with its observed refusal.
| `len = ...` | another name | error 16 | `mistake_reserved_name.om` |
| `neg = ...` or `text neg "a"` | another name: `neg` is the negation word | error 16 | `mistake_neg_name.om` |
| a bare call `f 1` with a result | `v = f 1` | error 7 | `mistake_value_stmt.om` |
+| `f add 2 1` (only bare numbers) to a `ulong` parameter | `f add ulong 2 1` | error 11 | `mistake_literal_op_arg.om` |
+| `x = g` (`bool`), later `x = write ...` (`long`) | one name per type | error 7 | `mistake_retype_name.om` |
| a 7th parameter | a struct or an array | error 9 | `mistake_seven_params.om` |
| 2 `view T *` plus 3 scalars (7 slots) | a sized view, a struct, or fewer scalars | error 9 | `mistake_om2_param_slots.om` |
| `emit buf` with `buf` a global | name the global inside the function | error 19 | `err19_global_arg.om` |