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

multimethods: Error: internal error: cgmeth.genConv #3550

Closed
Parashurama opened this issue Nov 17, 2015 · 4 comments
Closed

multimethods: Error: internal error: cgmeth.genConv #3550

Parashurama opened this issue Nov 17, 2015 · 4 comments

Comments

@Parashurama
Copy link
Contributor

the following code create a compiler error:

type
    BaseEvent* = object of RootObj
        data: pointer

    Control* = object of RootObj
        state: bool

    Button* = object of Control
        is_clicked : bool

    Dialog* = object of Control
        content: seq[RootObj]

method dummy_event*(self: Button, ev: BaseEvent) : bool {.base.} =
    discard

method dummy_event*(self: Dialog, ev: BaseEvent) : bool =
    discard

Error: internal error: cgmeth.genConv
No stack traceback available
To create a stacktrace, rerun compilation with ./koch temp c
main_module.nim(21, 21) Error: internal error: cgmeth.genConv
Traceback (most recent call last)
nim.nim(107) nim
nim.nim(71) handleCmdLine
main.nim(251) mainCommand
main.nim(63) commandCompileToC
modules.nim(221) compileProject
modules.nim(169) compileModule
passes.nim(206) processModule
passes.nim(129) closePasses
cgen.nim(1310) myClose
cgmeth.nim(259) generateMethodDispatchers
cgmeth.nim(231) genDispatcher
cgmeth.nim(21) genConv
msgs.nim(991) internalError
msgs.nim(965) liMessage
msgs.nim(837) handleError
msgs.nim(821) quit
FAILURE

VERSION:
Nim Compiler Version 0.12.1 (2015-11-15) [Linux: amd64]
Copyright (c) 2006-2015 by Andreas Rumpf

git hash: 0f7fdd8
active boot switches: -d:release


the problem disappear if BaseEvent changed to 'int' or another basic type but warn that second 'dummy_event' should have 'base' pragma.

Also the compiler doesn't accept 'base' pragma on second method if both arguments are objects

@Araq Araq closed this as completed in 698b1fc Nov 18, 2015
Araq added a commit that referenced this issue Nov 18, 2015
@Parashurama
Copy link
Contributor Author

Following on this issue

It seems to me that the following should to be the solution since their common ancestor doesn't have 'dummy_method'. But this doesn't work either! error: main_module.nim(18, 8) Error: method is not a base

Is this another bug or something i missed?

type
    BaseEvent* = object of RootObj
        data:pointer

    Control* = object of RootObj
        state: bool

    Button* = object of Control
        is_clicked : bool

    Dialog* = object of Control
        content: seq[RootObj]

method dummy_event*(self: Button, ev: BaseEvent) : bool {.base.} =
    discard

method dummy_event*(self: Dialog, ev: BaseEvent) : bool {.base.} =
    discard

@Araq Araq reopened this Nov 18, 2015
@Araq
Copy link
Member

Araq commented Nov 18, 2015

Whatever the compiler implements, it has to be consistent (right now it isn't) and in the spec.

@Parashurama
Copy link
Contributor Author

So, how this problem could be solved? Any workaround?

@jangko
Copy link
Contributor

jangko commented Nov 29, 2015

type
  ByteArray* = ref object of RootObj
  OutputStream* = ref object of RootObj

method CopyTo*(ba, target: ByteArray): int = discard
method CopyTo*(ba: ByteArray, os: OutputStream): int = discard

this is perhaps related with the above issue
the above code produce error message:

bytearray.nim(5, 8) Warning: use {.base.} for base methods; baseless methods are
 deprecated [UseBase]
bytearray.nim(5, 20) Error: there is no subtype relation between OutputStream an
d ByteArray

ver 0.11.2: compile success
0.12.0: failed with ICE
0.12.1: failed with no subtype relation

if the target param removed(which is undesired), no error

Araq added a commit that referenced this issue Dec 23, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants