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

Type Mismatch incomplete signature on error #12309

Open
SrMordred opened this issue Sep 30, 2019 · 7 comments
Open

Type Mismatch incomplete signature on error #12309

SrMordred opened this issue Sep 30, 2019 · 7 comments

Comments

@SrMordred
Copy link

Type mismatch error output shows incomplete type signature, making it harder to debug.

Example

Basic nimble package file +

requires "nim >= 1.0.0"
requires "jester"
requires "ws"

Source

import jester
import ws

routes:
    get "/":
        var ws = await newWebSocket(getNativeReq(request))

Current Output

nim_error/src/nim_error.nim(6, 36) Error: type mismatch: got <Request

but expected one of: 
	proc newWebSocket(req: Request): Future[WebSocket]
	first type mismatch at position: 1
	required type for req: Request
	but expression 'getNativeReq(request)' is of type: Request

Expected Output

nim_error/src/nim_error.nim(6, 36) Error: type mismatch: got <httpbeast.Request

but expected one of: 
	proc newWebSocket(req: Request): Future[WebSocket]
	first type mismatch at position: 1
	required type for req: asynchttpserver.Request
	but expression 'getNativeReq(request)' is of type: httpbeast.Request

Possible Solution

Don´t know :).
Apparently this only occurs with external packages. (Local file modules show the complete signature "module.type")

$ nim -v
Nim Compiler Version 1.0.99

@Araq
Copy link
Member

Araq commented Sep 30, 2019

Such a weird thing. Are you sure it's not caused by something like output redirections? (From Nimble or other tools...)

@SrMordred
Copy link
Author

nim c -r src/nim_error.nim give me the same output.

@Araq
Copy link
Member

Araq commented Oct 1, 2019

This does compile for me, so please setup a real test case which we can reproduce.

@SrMordred
Copy link
Author

I´m sorry. I should had informed at first: this fail on linux, because Jesters changes the Request type from asynchttpserver to httpbeast on linux only.

@disruptek
Copy link
Contributor

I read the error message, I read what you wrote, and I read the jester source and everything I read appears to be consistent. If you want to use a Request type that will match the required argument signature for the ws factory procedure newWebSocket, then you will need to compile with the -d:useStdLib so that the jester's Request used is the one from the standard library as required.

@SrMordred
Copy link
Author

SrMordred commented Oct 1, 2019

@disruptek My complain is not about the 'error' with Jester. (yes, I already solved it with the d:useStdlib :) )
Its about the error message not being clear about what happened:

required type for req: Request
but expression 'getNativeReq(request)' is of type: Request

Since it didn't prefixed the type with the module , it was a confusing error ( but my type IS Request :P )

If you simulate this problem on a local project, it displays the error correctly:
ex:

required type for myvar: Module1.TypeA
but expression ' myvar ' is of type: Module2.TypeA

Looks like imported packages from another package don´t show the module prefix.

@disruptek
Copy link
Contributor

You're right of course; I'm an idiot. I confused this for a new issue when I saw Araq's comment in my email. 😁

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