GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Bug: "x : i32 = test()" fails at top level · Issue #1667 · lcompilers/lpython

Bug: "x : i32 = test()" fails at top level #1667

New issue
Copy link
New issue
Copy link
Closed
#1672
Closed
Bug: "x : i32 = test()" fails at top level#1667
#1672
Copy link
Assignees
Thirumalai-Shaktivel
Labels
bugSomething isn't workingSomething isn't working

Description

@sarthakgupta0
sarthakgupta0
opened on Apr 5, 2023
Issue body actions

Running

def test() -> i32:
    temp: i32 = 0
    return temp

x : i32 = test()
# print(x)  Will give segmentation fault

gives code generation error: Function code not generated for 'test' .

But declaring and assigning in different line

x : i32
x = test()
print(x)

compiles successfully.
Not sure if this is intentional. This type of code runs fine in CPython.

Activity

  1. certik
    added
    bugSomething isn't workingSomething isn't working
    on Apr 5, 2023
  2. certik commented on Apr 5, 2023

    @certik
    certik
    on Apr 5, 2023
    Contributor
    More actions

    That's a bug, in fact two separate bugs, one a segfault, the other one "code generation error: Function code not generated for 'test'", both need to be investigated and fixed. Given how simple the code is, I think this is a high priority bug, so I put it into our roadmap: #1600. Thanks for reporting it!

  3. certik
    changed the title [-]Error : Function code not generated[/-] [+]Bug: "x : i32 = test()" fails at top level[/+] on Apr 5, 2023
  4. Thirumalai-Shaktivel commented on Apr 6, 2023

    @Thirumalai-Shaktivel
    Thirumalai-Shaktivel
    on Apr 6, 2023
    Collaborator
    More actions

    I think, I can see two issues here:
    1.

    def test() -> i32:
        temp: i32 = 0
        return temp
    
    x : i32 = test()

    The above code doesn't have any statements, so function-call to _lpython_main_program is not happening
    2.

    def test() -> i32:
        temp: i32 = 0
        return temp
    
    x : i32 = test()
    print(x)

    Here x is a global_variable and we are initializing it using a function call. I think that is the reason for the seg_fault.

  5. Thirumalai-Shaktivel
    self-assigned this
    on Apr 6, 2023
  6. Thirumalai-Shaktivel
    closed this as completedin #1672on Apr 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @Thirumalai-Shaktivel
    Thirumalai-Shaktivel

Labels

bugSomething isn't workingSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.