Skip to content

feat(sv)!: support shallow copies of class objects - #1810

Merged
mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb
Oct 26, 2026
Merged

mergify[bot] merged 1 commit into
masterfrom
stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb

Conversation

@tignear

@tignear tignear commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

new h creates an object of the class of the object that h refers to,
with a copy of its properties, without running a constructor or property
initializers; a property holding a handle keeps referring to the same object
(IEEE 1800-2023 8.12). The copy is assignment checked like any other handle,
and copying null is a runtime error.

The parser gives new h its own expression node, also as a variable
initializer, where it used to be accepted and dropped. The analyzer lowers
it to an object copy operation, and the heap copies the object, keeping its
handle properties visible to collection.

sv-tests: 8.12--shallow_copy passes (1081/1092 passing). Icarus 13.0 does not
parse shallow copies, which is recorded with evidence; Verilator passes the
shared case.

BREAKING CHANGE: celox_sv_syntax::ExprKind gains Copy and the analyzer IR
ObjectOp gains Copy.

Depends-On: #2093

@tignear

tignear commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

This pull request is part of a Mergify stack:

# Pull Request Link
1 feat(sv)!: support parameterized classes #1796
2 fix(sv): bind derived classes in their own declaration scopes #2093
3 feat(sv)!: support shallow copies of class objects #1810 👈
4 feat(sv): support classes declared in packages and the compilation unit #1850
5 feat(sv): let processes of several instances write a package variable #1872

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ⚠️ Failed 2026-10-26T00:25:19.984886Z
We couldn’t complete this review. Comment @codex review to try again.
0cc4b2e New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9831f346cc

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +507 to +510
let Some(source_class) = native_class(tree, *source, native, dimensions) else {
return Err(unsupported(
"shallow copy of a value that is not a class handle",
));

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 Support class-valued expressions as copy sources

When the shallow-copy operand is a class-valued function or method call, cast, or conditional expression—for example, C dst = new make_c();—native_class cannot determine its class because it only recognizes handle variables, selected array elements, and properties. This branch therefore reports that the value is not a class handle before bind_value runs, rejecting valid new expression shallow copies. Infer the operand's class from its expression type rather than requiring one of the narrow syntactic forms accepted by native_class.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #1891 (shallow copies of class-valued expressions, in any context and of null): these forms are rejected with a diagnostic today, not lowered wrongly.

Comment on lines +503 to +506
// `new h` copies the properties of the object of `h` into a new object
// of its class; handles are copied, not the objects they refer to (IEEE
// 1800-2023 8.12).
if let ExprKind::Copy(source) = &native.expression(ungroup(id, native)).kind {

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 Lower copy nodes in non-assignment expression contexts

A Copy node is lowered only when constructor is called for the complete right-hand side of an assignment, declaration initializer, or property initializer. In other valid contextual positions such as take(new h), return new h, or a conditional branch, normal bind_value traversal reaches the new node and rejects it as an unsupported primary expression, even when the formal, return, or enclosing assignment type supplies the required class. Handle ExprKind::Copy wherever a class-valued expression is bound, rather than only at top-level assignment sites.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #1891 (shallow copies of class-valued expressions, in any context and of null): these forms are rejected with a diagnostic today, not lowered wrongly.

Comment on lines +597 to +599
TokenKind::Identifier | TokenKind::EscapedIdentifier
) && (!self.reserved_identifier(token)
|| matches!(token.text.as_str(), "this" | "super"))

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 Accept null as a shallow-copy operand

The lookahead recognizes a shallow copy only when the token after new is a non-reserved identifier, this, or super, so an assignment such as C dst; initial dst = new null; does not produce ExprKind::Copy and fails during parsing instead of reaching the null-copy runtime fault implemented by this change. null is an expression operand of the new expression form, so it needs to be recognized here and typed from the destination context.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Tracked in #1891 (shallow copies of class-valued expressions, in any context and of null): these forms are rejected with a diagnostic today, not lowered wrongly.

@mergify

mergify Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Queued — the merge queue status continues in this comment ↓.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from c1e74be to b582538 Compare October 23, 2026 12:17
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 9831f34 to fd93137 Compare October 23, 2026 12:17
@tignear

tignear commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Revision history

# Type Changes Reason Date
1 initial 9831f34 2026-10-23 12:16 UTC
2 content 9831f34 → fd93137 Rebased onto the revised #1796 and master; sv-tests totals now 553/555. 2026-10-23 12:16 UTC
3 content fd93137 → 75eeaba Rebased onto the revised #1796 and master with class randomization: the copy opcode is 62, after the randomization opcodes, and a copy keeps the object's random state and modes (8.12); regenerated th… 2026-10-24 02:42 UTC
4 content 75eeaba → 2a56321 Rebased onto the revised #1796 and master. 2026-10-24 07:16 UTC
5 rebase 2a56321 → e11b661 (rebase only) Rebased onto the revised #1796. 2026-10-24 11:45 UTC
6 rebase e11b661 → d441141 (rebase only) Rebased onto the revised #1796. 2026-10-24 18:09 UTC
7 rebase d441141 → 458faa0 (rebase only) Rebased onto master with class enum randomization (#1859 and earlier); class test files merged and the Verilator/Icarus class reports regenerated. 2026-10-24 21:08 UTC
8 content 322bd44 → 9120d4d 2026-10-24 23:39 UTC
9 content 9120d4d → 06d0395 Rebased onto master: OBJECT_COPY moved to opcode 63 after randc took 62. Local review: a static class-handle property is accepted as a shallow-copy source. sv-tests totals 557/559. 2026-10-25 07:34 UTC
10 rebase 06d0395 → ce9510e (rebase only) 2026-10-25 10:59 UTC
11 content ce9510e → 0cc4b2e Rebased onto master: README paragraph moved to the current corpus (1081/1092); xezim review of shallow_copies. 2026-10-26 00:24 UTC

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from fd93137 to 75eeaba Compare October 24, 2026 02:43
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from b582538 to f3f644e Compare October 24, 2026 02:43
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from f3f644e to 76f7612 Compare October 24, 2026 07:17
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 75eeaba to 2a56321 Compare October 24, 2026 07:17
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 2a56321 to e11b661 Compare October 24, 2026 11:46
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from 76f7612 to a534644 Compare October 24, 2026 11:46
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from e11b661 to d441141 Compare October 24, 2026 18:17
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch 2 times, most recently from c6c132b to d9b70cf Compare October 24, 2026 21:08
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from d441141 to 458faa0 Compare October 24, 2026 21:08
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from d9b70cf to ba224ec Compare October 24, 2026 21:18
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 458faa0 to 322bd44 Compare October 24, 2026 21:18
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from ba224ec to e07fd68 Compare October 24, 2026 23:40
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 322bd44 to 9120d4d Compare October 24, 2026 23:40
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

1 similar comment
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from e07fd68 to 1f3bd97 Compare October 25, 2026 07:39
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 9120d4d to 06d0395 Compare October 25, 2026 07:40
@tignear

tignear commented Oct 25, 2026

Copy link
Copy Markdown
Contributor Author

Local review (Codex CLI) of this commit:

  • [P2] A static class-handle property is rejected as a shallow-copy source (dst = new Item::last;). Fixed: the copy resolves the class of a static property (h.p or C::p); covered by class::shallow_copies.

Rebased onto master: OBJECT_COPY is now opcode 63, since randc (#1959) took 62. sv-tests totals 557/559.

@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 branch from 1f3bd97 to 880e92e Compare October 25, 2026 11:00
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from 06d0395 to ce9510e Compare October 25, 2026 11:00
`new h` creates an object of the class of the object that `h` refers to,
with a copy of its properties, without running a constructor or property
initializers; a property holding a handle keeps referring to the same object
(IEEE 1800-2023 8.12). The copy is assignment checked like any other handle,
and copying `null` is a runtime error.

The parser gives `new h` its own expression node, also as a variable
initializer, where it used to be accepted and dropped. The analyzer lowers
it to an object copy operation, and the heap copies the object, keeping its
handle properties visible to collection.

sv-tests: 8.12--shallow_copy passes (1081/1092 passing). Icarus 13.0 does not
parse shallow copies, which is recorded with evidence; Verilator passes the
shared case.

BREAKING CHANGE: celox_sv_syntax::ExprKind gains Copy and the analyzer IR
ObjectOp gains Copy.

Change-Id: Iace3f3bb801198a7b371c95fdb979244dbd95fb4
@tignear
tignear changed the base branch from stack/tignear/feat/string-class-heap/support-parameterized-classes--45d02629 to master October 26, 2026 00:24
@tignear
tignear force-pushed the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch from ce9510e to 0cc4b2e Compare October 26, 2026 00:25
@tignear
tignear changed the base branch from master to stack/tignear/feat/string-class-heap/bind-derived-classes-their-own-declaration-scopes--7b2b0f70 October 26, 2026 00:25
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

Base automatically changed from stack/tignear/feat/string-class-heap/bind-derived-classes-their-own-declaration-scopes--7b2b0f70 to master October 26, 2026 02:06
@tignear tignear added the merge-ready Request merging through Mergify after required checks label Oct 26, 2026
@mergify mergify Bot added the queued Mergify queue entry label Oct 26, 2026
@mergify

mergify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-26 02:09 UTC · Rule: changes · triggered by rule Queue explicitly requested merges
  • ✅ Checks passed · on draft merge queue: checking #1810 on master (05a48de) #2096
  • ✅ Merged — 2026-10-26 02:37 UTC · at a4b02fb4917501b446d549536782c160f745f768 · merge

This pull request spent 28 minutes 28 seconds in the queue, including 26 minutes 48 seconds running CI.

Required conditions to merge
  • check-success = Conventional Commit title
  • check-success = Queue validation
  • depends-on = celox-sim/celox#2093 [⛓️ fix(sv): bind derived classes in their own declaration scopes #2093]
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Lint & Format
    • check-neutral = @github-actions/Lint & Format
    • check-skipped = @github-actions/Lint & Format
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-neutral = @github-actions/NAPI Build (Linux ARM64 GNU)
    • check-skipped = @github-actions/NAPI Build (Linux ARM64 GNU)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/NAPI Build (Windows)
    • check-neutral = @github-actions/NAPI Build (Windows)
    • check-skipped = @github-actions/NAPI Build (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Rust Test & NAPI Build
    • check-neutral = @github-actions/Rust Test & NAPI Build
    • check-skipped = @github-actions/Rust Test & NAPI Build
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Ubuntu)
    • check-neutral = @github-actions/JS Test (Ubuntu)
    • check-skipped = @github-actions/JS Test (Ubuntu)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/JS Test (Windows)
    • check-neutral = @github-actions/JS Test (Windows)
    • check-skipped = @github-actions/JS Test (Windows)
  • any of [🛡 GitHub repository ruleset rule master]:
    • check-success = @github-actions/Conventional Commit title
    • check-neutral = @github-actions/Conventional Commit title
    • check-skipped = @github-actions/Conventional Commit title

@mergify mergify Bot mentioned this pull request Oct 26, 2026
43 of 73 tasks
@mergify
mergify Bot merged commit a4b02fb into master Oct 26, 2026
26 checks passed
@mergify
mergify Bot deleted the stack/tignear/feat/string-class-heap/support-shallow-copies-class-objects--ace3f3bb branch October 26, 2026 02:37
@mergify mergify Bot removed the queued Mergify queue entry label Oct 26, 2026
@mergify mergify Bot mentioned this pull request Oct 26, 2026
43 of 73 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-ready Request merging through Mergify after required checks

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant