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

Wrong method called #5439

Closed
simonkrauter opened this issue Feb 25, 2017 · 3 comments
Closed

Wrong method called #5439

simonkrauter opened this issue Feb 25, 2017 · 3 comments
Labels

Comments

@simonkrauter
Copy link
Contributor

simonkrauter commented Feb 25, 2017

Sample program:

type
  Control* = ref object of RootObj

  ControlImpl* = ref object of Control

  Container* = ref object of ControlImpl

  ContainerImpl* = ref object of Container

method testProc*(control: Control) = echo "wrong method"
  
method testProc*(container: Container) = echo "correct method"
    
proc main()

main() # wrong method called

proc main() =
  var container = new ContainerImpl
  container.testProc()

# main() # correct method called

If "main()" is called below, the method of Container is called, which is correct.
If "main()" is called above, the method of Control is called, which is wrong.

Tested under Arch Linux AMD64 with Nim 0.16.0 and 0.16.1 (2017-02-25).

@Araq Araq added the Methods label Feb 25, 2017
@Araq
Copy link
Member

Araq commented Feb 25, 2017

Cannot reproduce. Works for me for every OS/Nim version that I try.

@simonkrauter
Copy link
Contributor Author

New info: happens only when compiling with d:release.

@Araq
Copy link
Member

Araq commented Feb 26, 2017

Ha, indeed.

@Araq Araq closed this as completed in fb37d13 Feb 26, 2017
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

2 participants