Skip to content

feat: map defined types declared inside a function - #214

Merged
conr2d merged 1 commit into
mainfrom
feat/local-defined-types
Dec 4, 2026
Merged

conr2d merged 1 commit into
mainfrom
feat/local-defined-types

Conversation

@4lmighty

@4lmighty 4lmighty commented Dec 4, 2026

Copy link
Copy Markdown
Collaborator

Summary

A defined type declared inside a function, such as type testFunc func(*Changer, []*pb.ConfChangeSingle) error in etcd raft's TestConfChangeQuick, is now a local struct derived from eo::defined<T, U>. Like a local interface (#210), it writes _eo_name as a static member function, because C++ allows a local class no static data members.

The library already reads both forms of _eo_name since #210, so no library change was needed. This PR adds the rule and a parity case.

  • docs/TRANSLATION_RULES.md: a new "Defined types declared inside a function" section. The not-covered list now names only the remaining case, a local defined type over a local struct, which has no _eo_name.
  • tests/parity/local_defined_types: defined types over float64, string, []uint64, a map, a function, and a package-level struct, declared in main. It checks conversions, operators, comparisons, append and slicing, map entries, nil function values, %T/%v/%+v/%#v, type assertions, a type switch that tells IDs from []uint64, and interface equality.

Test plan

  • parity.local_defined_types.{cpp,go} pass, along with the other defined_* and local_interfaces cases.
  • Mutation: a wrong _eo_name for IDs fails the C++ case.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WKhFr4YH1YUGTnN1iSi9bQ

A defined type declared inside a function is a local struct derived from
eo::defined, with _eo_name as a static member function, the form #210 gave
local interfaces. The library already reads both forms of _eo_name, so this
adds the rule and a parity case over basic, string, slice, map, function,
and struct underlying types. etcd raft's TestConfChangeQuick needs it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WKhFr4YH1YUGTnN1iSi9bQ
@conr2d
conr2d merged commit a0b0c66 into main Dec 4, 2026
6 checks passed
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.

2 participants