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

Default arguments do not compile to Libra #6

Open
egroge opened this issue Jul 7, 2020 · 2 comments
Open

Default arguments do not compile to Libra #6

egroge opened this issue Jul 7, 2020 · 2 comments
Assignees
Labels
bug Something isn't working move ir Code generation for Libra

Comments

@egroge
Copy link
Collaborator

egroge commented Jul 7, 2020

The following issue appears in flintlang/flint-2/master and returns a fatal error. When writing a function that operates on a struct, the use of a default parameter causes the code generation to fail. Note that this issue only appears when compiling with libra as the target.

struct SomeStruct {
    public var width: Int

    // Works
    public func increaseWidth(arg: Int) {
        self.width = self.width + arg
    }

    // Also works (so it does not seem to be an issue of having access to self)
    public func increaseWidth(arg: Int) {}

    // Does not work (using an int literal in place of width has the same effect)
    // replacing width with self.width also does not work
    public func increaseWidth(arg: Int = width) {}
}
@egroge egroge added bug Something isn't working move ir Code generation for Libra labels Jul 7, 2020
@mrRachar
Copy link
Collaborator

mrRachar commented Jul 7, 2020

Just to check, I'm imagining that ...(arg: Int = self.width) also doesn't work.

@mrRachar mrRachar changed the title Default arguments do not compile to libra Default arguments do not compile to ibra Jul 7, 2020
@mrRachar mrRachar changed the title Default arguments do not compile to ibra Default arguments do not compile to Libra Jul 7, 2020
@mrRachar mrRachar added this to the Spec compatibility milestone Jul 7, 2020
@egroge
Copy link
Collaborator Author

egroge commented Jul 7, 2020

Yes you are correct, I have updated the issue

@mrRachar mrRachar self-assigned this Aug 18, 2020
@mrRachar mrRachar mentioned this issue Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working move ir Code generation for Libra
Projects
None yet
Development

No branches or pull requests

2 participants