Skip to content

Need Ch 4.3: Show how type inference interacts with dead code elimination #11

@seibert

Description

@seibert

We want the compiler to be able to handle situations like this function:

def myfunc(return_int=True):
    if return_int:
        x = 1
    else:
        x = 1.0
    return x

(For this example, I'm assuming no implicit casting between int and float and the value of const_arg is known at compile time.)

Under the type inference rules of Ch 4.1, this will fail to unify because the then-region will infer the type of x to be an int, and the else-region will infer the type to be a float. However, if we also have a rule in the compiler that allows a branch with a constant condition to be replaced by the contents of the selected region, then there is no need to unify incompatible types across the two regions. How should this be handled in egglog?

Metadata

Metadata

Assignees

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