Skip to content

unable to identify undefined values in class #903

@gesslar

Description

@gesslar
class L {
    string m ;
    int n ;
    float o ;
}

void runit()
{
    class L l = new(class L) ;
    int x = 3 ;

    printf("l: %O\n", l) ;
    printf("nullp(l->m): %O\n", nullp(l->m)) ;
    printf("undefinedp(l->n): %O\n", undefinedp(l->n)) ;
    printf("typeof(l->o): %O\n", typeof(l->o)) ;

    while(x--)
    {
        printf("%O",
            sprintf("MEMBER #: %O\n", x) +
            sprintf(sprintf("VALUE: %O\n", fetch_class_member(l, x))) +
            sprintf(sprintf("TYPEOF: %O\n", typeof(fetch_class_member(l, x)))) +
            sprintf(sprintf("NULLP: %O\n", nullp(fetch_class_member(l, x)))) +
            sprintf(sprintf("UNDEFINEDP: %O\n", undefinedp(fetch_class_member(l, x))))
        ) ;
    }
}

results:

l: CLASS( 3 elements
  0,
  0,
  0
 )
nullp(l->m): 0
undefinedp(l->n): 0)
typeof(l->o): "int"
"MEMBER #: 2
VALUE: 0
TYPEOF: "int"
NULLP: 0
UNDEFINEDP: 0
""MEMBER #: 1
VALUE: 0
TYPEOF: "int"
NULLP: 0
UNDEFINEDP: 0
""MEMBER #: 0
VALUE: 0
TYPEOF: "int"
NULLP: 0
UNDEFINEDP: 0
"

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