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

Cannot use default parameters on init method #844

Open
supercooldave opened this issue Jul 4, 2017 · 0 comments
Open

Cannot use default parameters on init method #844

supercooldave opened this issue Jul 4, 2017 · 0 comments
Labels

Comments

@supercooldave
Copy link

Using default parameters on the init method results in compilation errors. For example,

local class A
  -- does not compile
  def init(i : int = 0) : unit
    println(i)
  end
  
  -- compiles and works
  def other(i : int = 0) : unit
    println(i)
  end
end

results in error:

"Init.enc" (line 3, column 3)
Constructor method 'init' can only be called during object creation
In expression: 
  this.init(0)
In expression: 
  return(this.init(0))
In method '_init1' of type 'unit'
In class 'A'

This is undoubtedly due to the way methods using default parameters are compiled, which is incompatible with the restrictions on init.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant