Skip to content

fix(frontend): allow typed object nil equality - #47

Merged
SuperIceCN merged 6 commits into
masterfrom
fix/frontend/issue-44
Jun 23, 2026
Merged

fix(frontend): allow typed object nil equality#47
SuperIceCN merged 6 commits into
masterfrom
fix/frontend/issue-44

Conversation

@SuperIceCN

Copy link
Copy Markdown
Collaborator

Summary

This PR fixes frontend semantic resolution for typed object and null equality so ordinary nullable-object guards compile without sentinel workarounds. It aligns frontend typing and compile checks with the existing backend nil-comparison path.

What changed

  • Added a narrow frontend semantic rule so == and != between typed object values and Nil resolve to bool instead of falling through to builtin operator metadata failure.
  • Updated frontend compile/lowering flow coverage to keep typed object null guards lowering-ready.
  • Added frontend, lowering, backend, and test-suite coverage for object-nil equality and for rejecting unsupported ordering operators.
  • Restored benchmark/test scripts to use direct nullable-object checks instead of sentinel-style workarounds.
  • Folded the final semantic notes back into the frontend unary/binary expression implementation document.

Why

  • Issue frontend: typed object null equality is rejected before nil comparison lowering #44 exposed a frontend/backend contract mismatch: backend codegen already supports object-nil comparison, but frontend semantic typing rejected the same operand pair before lowering.
  • That rejection blocked normal source shapes such as current != null in typed linked structures and forced benchmark code to avoid ordinary nullable-object guards.
  • Keeping the rule narrow to equality operators preserves existing operator constraints while making typed object null checks compile as expected.

Affected packages/files

  • gd.script.gdcc.frontend.sema.analyzer
  • gd.script.gdcc.frontend.sema.analyzer.support
  • gd.script.gdcc.frontend.lowering.cfg.item
  • gd.script.gdcc.backend.c.gen
  • src/test/test_suite/unit_test/script/smoke/object_nil_equality.gd
  • doc/module_impl/frontend/frontend_unary_binary_expr_semantic_implementation.md

Validation

  • ./gradlew test --tests FrontendCompileCheckAnalyzerTest --tests FrontendExpressionSemanticSupportTest --tests FrontendLoweringBodyInsnPassTest --tests COperatorInsnGenTest --tests GdScriptUnitTestCompileRunnerTest --no-daemon --info --console=plain
  • ./gradlew classes --no-daemon --info --console=plain

Result: BUILD SUCCESSFUL

Risks / Notes

  • The semantic special case remains intentionally narrow: only == and != for object-Nil and Nil-Nil pairs are accepted.
  • Ordering operators for object-nil pairs still fail and remain covered by tests.
  • The PR also includes the benchmark/test fixture cleanup needed to exercise the real nullable-object source shape.

Key behaviors covered (Optional)

  • typed_object == null and typed_object != null resolve to bool.
  • null == typed_object and null != typed_object resolve to bool.
  • null == null and null != null resolve to bool.
  • typed_object < null remains rejected.
  • Typed object while current != null guards compile through frontend/lowering and reach backend nil-comparison handling.

Diff stats (Optional)

  • 15 files changed, 403 insertions, 39 deletions.

Breaking changes (Optional)

  • None

Related docs (Optional)

  • doc/module_impl/frontend/frontend_unary_binary_expr_semantic_implementation.md

Closes #44

- document issue #44 scope and failure chain
- explain why frontend should keep BinaryOpInsn and NIL_COMPARISON
- capture phased implementation and acceptance checks
- Narrow issue scope to typed object/null equality while preserving wider backend Nil semantics.
- Ground Godot evidence in parser, analyzer, and Variant operator contracts.
- Add Variant/DYNAMIC null regression expectations to prevent special-rule capture.
- Resolve object/null and null/null equality as bool in binary semantic support
- Preserve Variant/DYNAMIC runtime-open routing and object/null ordering failures
- Cover semantic, compile-check, lowering, and backend nil-comparison regressions
- Sync frontend nil equality plan and unary/binary semantic documentation
- Add compile-check regression for object/null ordering failures.
- Document Phase 3 coverage for equality-only nil comparison.
- Add smoke fixture for typed object/null equality true and false runtime cases.
- Replace quadtree sentinel points with direct null-linked traversal.
- Record focused and benchmark validation in the frontend equality plan.
…ract

- merge the archived object/nil equality facts into the unary/binary semantic source of truth
- delete the redundant standalone archive document
- rewrite phase-oriented frontend comments as current stable contracts
@SuperIceCN
SuperIceCN merged commit bea1bad into master Jun 23, 2026
1 check passed
@SuperIceCN
SuperIceCN deleted the fix/frontend/issue-44 branch June 23, 2026 13:08
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.

frontend: typed object null equality is rejected before nil comparison lowering

2 participants