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

link time error: multiple definition of method #5201

Closed
lbguilherme opened this issue Oct 28, 2017 · 0 comments · Fixed by #5202
Closed

link time error: multiple definition of method #5201

lbguilherme opened this issue Oct 28, 2017 · 0 comments · Fixed by #5202

Comments

@lbguilherme
Copy link
Contributor

This code:

def a(x)
  x
end

class A
  def a(x)
    super x
  end
end

a "1"
A.new.a "2"

Causes:

A-.o: In function `a':
/home/guilherme/Cubos/sdkgen2/x.cr:3: multiple definition of `*a<String>:String'
_main.o:/home/guilherme/Cubos/sdkgen2/x.cr:3: first defined here
collect2: error: ld returned 1 exit status
Error: execution of command failed with code: 1: `cc "${@}" -o '/home/guilherme/.cache/crystal/crystal-run-x.tmp'  -rdynamic  -lpcre -lgc -lpthread /opt/crystal/src/ext/libcrystal.a -levent -lrt -ldl -L/usr/lib -L/usr/local/lib`

This happens on both lastest release (Crystal 0.23.1 [e2a1389] (2017-07-13) LLVM 3.8.1) and current master (Crystal 0.24.0 [ea4187c] (2017-10-28) LLVM 4.0.1).

Obviously the code makes no sense, there is no "super" to invoke. But it surely should report correct error. This is my expected output:

Error in x.cr:12: instantiating 'A#a(String)'

A.new.a "2"
      ^

in x.cr:7: undefined method 'a'

    super x
    ^~~~~
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 a pull request may close this issue.

1 participant