Skip to content

Compilation failure for unused class used in instanceof expr #68

@quasilyte

Description

@quasilyte
<?php

class Bar {}
class Foo extends Bar {}

function f(Bar $f) {
  var_dump($f instanceof Foo);
}

f(null);

// - Foo is "unused" and will not be generated
// - instanceof produces unconditional class_dep on Foo
// - we get Can't find header cl/C@Foo.h required by o_0/f.h + compiler crash

class_dep is added here:

if (auto instanceof = vertex.try_as<op_instanceof>()) {
current_function->class_dep.insert(instanceof->derived_class);
}

Possible solutions:

  • Don't add class_dep for unused classes?
  • Don't try to add a header for unused class?
  • Mark class as used if it was reachable from instanceof from a used function?
  • ...

I'll reference another related problem to this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions