← 输入框|github.com|刷新
Skip to content

Symbolic Pass failing in LFortran #2553

Closed

Description

@anutosh491

This issue was brought up here (lfortran/lfortran#3432 (comment))

We were lucky to not have encountered this issue in Lpython itself. Consider the following

def main0():
    x: S = Symbol('x')
    y: S = Symbol('y')
    z: S = x + y
    print(z.func == Add)

main0()

So this is an example which is solved by the code in consideration

} else if (ASR::is_a<ASR::Logical_t>(*ASRUtils::expr_type(val))) {
ASR::expr_t* function_call = process_attributes(x.base.base.loc, val);
print_tmp.push_back(function_call);

Activity

  1. anutosh491 commented on Feb 24, 2024

    @anutosh491
    CollaboratorAuthor

    Now the ASR node we have is this

        (Print
            [(IntrinsicScalarFunction
                SymbolicAddQ
                [(Var 13 z)]
                0
                (Logical 4)
                ()
            )]
            ()
            ()
        )
    

    So we are trying to print an IntrinsicScalarFunction that is of type Logical (and luckily as of now we don't have any other intrinsic function of logical type registered, all logical type intrinsic functions are for solving symbolic cases)

    But let's say we introduce a logical intrinsic function say ListIsEmpty which would be of type Logical, how can we separate this from the functions (intrinsic + logical) that are serving a symbolic purpose (like SymbolicAddQ) ?

  2. certik commented on Feb 24, 2024

    @certik
    Contributor

    @anutosh491 go ahead and fix this one as a high priority, so that we can enable the symbolic pass in all frontends.

  3. certik commented on Feb 28, 2024

    @certik
    Contributor

    This condition } else if (ASR::is_a<ASR::Logical_t>(*ASRUtils::expr_type(val))) { must be improved to ALSO check for the node to be intrinsic symbolic.

  4. certik commented on Feb 28, 2024

    @certik
    Contributor

    Right below the line ASR::IntrinsicScalarFunction_t* intrinsic_func = ASR::down_cast<ASR::IntrinsicScalarFunction_t>(val); you need to check that intrinsic_func.id is a symbolic function. Otherwise you ignore it.

  5. certik commented on Feb 28, 2024

    @certik
    Contributor

    Create a function is_symbolic_intrinsic where inside you hardwire (for now) all the symbolic intrinsic IDs.

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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions