Implement object inheritance: # Child = > Parent (I0-I2)

- Parse `# Child = > Parent` object decls (base must be a simple
  name after `>`; dotted bases and `# Foo = 1` are diagnostics).
- Validate in load: unknown base types and cyclic inheritance (A → B → A)
  fail with line/col.
- Method resolution walks the base chain (most specific first) on both
  tree and bytecode backends; `_type` stays the child name; same-name
  child ## overrides the parent.
- Add inherit.rs, wire Program.object_bases, gold fixtures
  (inherit-parent-method / inherit-override + cycle/unknown-base/bad-rhs)
  and public 09-inherit demo pages. Docs: objects.md, markdown-mapping,
  roadmap, skill.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
cflmyandCursor committed 2026-08-10 10:01:05 +08:00
1 parent a23fdedfa2
commit 5456d9ff83
25 files changed
+590 -41

No files matched your search

+1 -1
View File
@@ -30,7 +30,7 @@ Canonical design (repo): `doc/design/markdown-mapping.md`, `doc/design/keywords.
| Marker | Meaning |
|--------|---------|
| `#` | **Object / type** (constructor body). `# main` = entry object. |
| `#` | **Object / type** (constructor body). `# main` = entry object. `# Child = > Parent` = inherit. |
| `##` … `######` | **Function / method** (nesting by heading depth). |
| `` + `name` `` under heading | Parameter (optional `` `name`=default ``) |
| `1.` `2.` … in body | Branch arm (condition or `N. *` else). **Same-indent restart at `1.` = new branch statement** (not more arms of the previous list). |
+22
View File
@@ -155,6 +155,28 @@ description: loads math
See `tests/structure/object-handle.mq.md` and `ext/llm.mq.md`: `# Type` constructs a map with `_type`; methods use `` > `obj`.method `` and read `self` / `自`.
## 10b. Object inheritance
```markdown
# Greeter
## hello
+ `who`
*`msg` = "Hello, `who`!" *
**`msg`**
# Loud = > Greeter
## hello
+ `who`
*`msg` = "HELLO, `who`!" *
**`msg`**
```
`_type` stays the most specific name (`Loud`). Methods walk the base chain; same-name `##` on the child overrides. No implicit super in v1.
## 11. Agent layout (ABI)
```markdown