Skip to content

Null check missed guard? #246

Description

@dibyendumajumdar

This test program failed in chapter 21

struct Point { int x; };

Point?[] !points = new Point?[2];
points[arg] = new Point { x = 42; };
Point? p = points[1];

if (p != null)
    return p.x;

return -1;

Error reported

Exception in thread "main" com.seaofnodes.simple.Parser$ParseException: Might be null accessing 'x'
	at com.seaofnodes.simple.Parser.error(Parser.java:1743)
	at com.seaofnodes.simple.node.MemOpNode.err(MemOpNode.java:108)
	at com.seaofnodes.simple.node.Node._walk(Node.java:708)
	at com.seaofnodes.simple.node.Node._walk(Node.java:711)
	at com.seaofnodes.simple.node.Node._walk(Node.java:711)
	at com.seaofnodes.simple.node.Node._walk(Node.java:710)
	at com.seaofnodes.simple.node.Node._walk(Node.java:710)
	at com.seaofnodes.simple.node.Node._walk(Node.java:710)

Activity

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