Skip to content

Reflect.hasField misses fields in fixed anonymous objects #222

Closed

Description

@dimensionscape

Reflect.hasField returns false for fields in @:fixed anonymous objects, even though Reflect.field and Reflect.fields find those same fields.

Regression coverage first: test/regression/AnonFixedReflection, using the existing Main.hx/build.hxml/stdout.txt layout:

var value = @:fixed {answer: 42};
Sys.println(Reflect.field(value, "answer"));
Sys.println(Reflect.hasField(value, "answer"));
Sys.println(Reflect.fields(value).join(","));

Confirmed on Linux x86_64 with Haxe 4.3.3:

field: 42
hasField: false
fields: answer

Haxe Eval reports hasField: true for the same program. A missing field should still report false, and an existing field with a null value must report true.

include/hx/Anon.h provides AnonStruct1_obj through AnonStruct5_obj with __Field, __SetField and __GetFields overrides but no __HasField override. They inherit Object::__HasField from src/hx/Object.cpp, which always returns false. Ordinary Anon_obj implements its own existence query and does not have this problem.

Implement field existence consistently for every fixed anonymous-object arity, including null-valued fields and runtime-created field-name strings. This is relevant to structural typedef values emitted through the fixed-anon representation and to reflection-based validation or serialization that checks existence before reading.

The local regression is added before any implementation change. No runtime implementation changes are included.

Activity

  1. added a commit that references this issue on Oct 20, 2026
    acb242e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions