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

1.9 broke my call to NanThrowError #390

Closed
LinusU opened this issue Aug 1, 2015 · 7 comments
Closed

1.9 broke my call to NanThrowError #390

LinusU opened this issue Aug 1, 2015 · 7 comments

Comments

@LinusU
Copy link
Contributor

LinusU commented Aug 1, 2015

LinusU/fs-xattr#8

The following code works in 1.8.x but not in 1.9.

void ThrowExceptionErrno(int e) {

  Local<Object> err = v8::Exception::Error(NanNew(errorDescriptionForGet(e)))->ToObject();
  err->Set(NanNew("errno"), NanNew<Integer>(e));
  err->Set(NanNew("code"), NanNew(errorCode(e)));

  NanThrowError(err);
}

This is the error:

In file included from ../src/xattr.cc:21:
../src/error.cc:109:3: error: call to 'NanThrowError' is ambiguous
  NanThrowError(err);
  ^~~~~~~~~~~~~
../node_modules/nan/nan.h:711:3: note: candidate function
  X(Error)
  ^
../node_modules/nan/nan.h:705:21: note: expanded from macro 'X'
    NAN_INLINE void NanThrow ## NAME(v8::Handle<v8::String> errmsg) {          \
                    ^
<scratch space>:93:1: note: expanded from here
NanThrowError
^
../node_modules/nan/nan.h:719:19: note: candidate function
  NAN_INLINE void NanThrowError(v8::Handle<v8::Value> error) {
                  ^

I think that maybe this is because of #322

@LinusU
Copy link
Contributor Author

LinusU commented Aug 1, 2015

This code doesn't work as well:

NanThrowError(NanErrnoException(errno));

@LinusU
Copy link
Contributor Author

LinusU commented Aug 1, 2015

The workaround/fix is quite easy thought:

NanThrowError((v8::Handle<v8::Value>) err);

@bnoordhuis
Copy link
Member

I speculate you're hitting a compiler bug. Two NanThrowError overloads exist, one for v8::Handle<v8::Value> and one for v8::Handle<v8::String>, but they cannot conflict here: v8::Object is an instance of v8::Value but not v8::String, there is no ambiguity here.

I don't have any off-the-cuff suggestions on how to fix this in nan but what happens when you rewrite the call to NanThrowError(err.As<v8::Value>())?

EDIT: Concurrent post. :-)

@LinusU
Copy link
Contributor Author

LinusU commented Aug 1, 2015

Yeah I thought it was strange, hmm.

Just published the fix I just posted, is there any benefit in doing err.As<v8::Value>() instead?

@bnoordhuis
Copy link
Member

.As<T>() adds a bit more type-safety than a C style (or even C++ style) cast does. Apart from that, they're identical.

@LinusU
Copy link
Contributor Author

LinusU commented Aug 1, 2015

Cool, I guess that it's more idiomatic then 👍

@kkoopa
Copy link
Collaborator

kkoopa commented Aug 2, 2015

The tests don't complain with our compilers.

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

No branches or pull requests

3 participants