-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Passing an exception into ccall as string sends empty string #17766
Comments
Certainly seems like we could use an assert about the type of |
I haven't tried building the compiler before; Is this the code I need to change? (I assume this isn't auto-generated code?) emscripten/src/library_ccall.js Line 26 in 5667b03
|
Yes, that is the where the ccall code lives. |
Also, is |
I think an assert is the right solution here. |
Version of emscripten/emsdk: 3.1.20-git (from homebrew)
This is user-error, but feels like it should have been caught higher up (maybe in the string/stack alloc?), and should be a simple UX fix
I passed an exception into ccall;
Didn't twig it wasn't a string for a while as chrome's debugger shows it as a string, the type convertor doesn't error, (and debugger even makes it look like a string), and it manages to allocate & copy a string (of length 1) because
var len = (str.length << 2) + 1; -->
var len = (undefined << 2) + 1; == 1
Feels to me like either
a) convertor should throw if object has no length property (or just isn't a string!) thereby forcing users to pass strings if they said they would
b) force the input value to be a string
str =
${str}` (so type takes precedent)(Screenshot to highlight UX)
The text was updated successfully, but these errors were encountered: