Skip to content
This repository was archived by the owner on Feb 2, 2024. It is now read-only.
This repository was archived by the owner on Feb 2, 2024. It is now read-only.

Invalid result for HO function with bound instancemethod argument #63

Description

@quasilyte

Numba does partially support higher-order functions and local closures, but the boundaries are not clearly defined as well as the inlining effect on it.

For HPAT, code below actually results in invalid results and no JIT compilation time error.
We should fix this bug and properly document what kinds of callable values HPAT supports.
After that, it would be simpler to give proper error messages to the user.
Right now it's unclear what are should be compiled and what should result in a compilation error.

Reproducer:

import hpat
import pandas as pd

# Higher-order function
@hpat.jit
def indirect(call, fn):
    if call:
        return fn()
    return 0

@hpat.jit
def weird():
    df = pd.DataFrame({'A': [1]})
    return indirect(False, df.head)


# This one works fine
@hpat.jit
def indirect_ok(fn):
    return fn()

@hpat.jit
def works_as_expected():
    df = pd.DataFrame({'A': [1]})
    return indirect_ok(df.head)

print(weird())
print(works_as_expected())

Results for code without @hpat.hit decorator:

0
   A
0  1

Results for code with JIT:

Empty DataFrame
Columns: [A]
Index: []
   A
0  1

No activity

Activity on this issue will appear here.

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