Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

User-friendly error message for missing main function #509

Merged
merged 26 commits into from
Aug 21, 2024

Conversation

littlewhitecloud
Copy link
Contributor

@littlewhitecloud littlewhitecloud commented Jul 9, 2024

fix #210

  • An error that says clearly there is no main function, if the file you try to run doesn't define a main function.
  • An error if you try to import a file that defines a main function.

@littlewhitecloud
Copy link
Contributor Author

littlewhitecloud commented Jul 13, 2024

@Akuli
This pr will make tests\should_succeed\import_cycle.jou fail
So I moved it from should_succeed to other_errors

@Akuli
Copy link
Owner

Akuli commented Aug 17, 2024

@littlewhitecloud Sorry that it took so long for me to start working on this :)

I am now quite happy with how it works. C code is reasonably clean, error messages are good, existing and new tests are passing.

But I haven't updated the self-hosted compiler. Can you do that? :)

@littlewhitecloud
Copy link
Contributor Author

@littlewhitecloud Sorry that it took so long for me to start working on this :)

I am now quite happy with how it works. C code is reasonably clean, error messages are good, existing and new tests are passing.

But I haven't updated the self-hosted compiler. Can you do that? :)

I need some time to know what changed :) But now I'm a little busy and I will be back to school soon XD
So I am not sure if I can update the self-hosted compiler, Sorry.

@littlewhitecloud
Copy link
Contributor Author

Ok I just got time but is there find_file function in self-hosted compiler?

@Akuli
Copy link
Owner

Akuli commented Aug 19, 2024

This loop in main.jou is basically the find_file function. It is not in a separate function, so you can either copy/paste the loop, or make a new function (or method) that does it.

            found = False
            for i = 0; i < self->nfiles; i++:
                if strcmp(self->files[i].ast.path, item.path) == 0:
                    found = True
                    break

@littlewhitecloud
Copy link
Contributor Author

littlewhitecloud commented Aug 20, 2024

What's the return type @Akuli ?

def find_file(files: FileState*, nfiles: int, path: byte*) -> ?:
    for i = 0; i < nfiles; i++:
        if strcmp(files[i].ast.path, path) == 0:
            return files[i]
    return NULL

@Akuli
Copy link
Owner

Akuli commented Aug 20, 2024

I have added a few review comments. Let me know if you need more help :)

@littlewhitecloud
Copy link
Contributor Author

I have added a few review comments. Let me know if you need more help :)

Thanks!

Copy link
Owner

@Akuli Akuli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@Akuli Akuli merged commit 7c2f683 into Akuli:main Aug 21, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

user-friendly error message for missing main func
2 participants