Skip to content

Uncaught ReferenceError: upper is not defined, uuid_unparse #21056

@taemincho

Description

@taemincho

Please include the following in your bug report:

Version of emscripten/emsdk:

emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.51 (c0c2ca1314672a25699846b4663701bcb6f69cca)
clang version 18.0.0git (https://github.com/llvm/llvm-project f2464ca317bfeeedddb7cbdea3c2c8ec487890bb)
Target: wasm32-unknown-emscripten
Thread model: posix

Failing command line in full:
N/A

Full link command and output with -v appended:

--bind -sENVIRONMENT=shell,web -sSINGLE_FILE=1 -sWASM=1 -sMAXIMUM_MEMORY=4GB -sALLOW_MEMORY_GROWTH=1 -sWASM_ASYNC_COMPILATION=0 -sEXPORTED_FUNCTIONS="['_malloc', '_free']" -O0 --extern-post-js post.js 

I encountered an error: Uncaught ReferenceError: upper is not defined when attempting to load the compiled wasm module. This issue arises from the auto-generated uuid_unparse function, which is missing the upper argument. The problematic portion of the code looks like this:

/** @param {number|boolean=} upper */ function _uuid_unparse(uu, out) {
 uu >>>= 0;
 out >>>= 0;
 var i = 0;
 var uuid = "xxxx-xx-xx-xx-xxxxxx".replace(/[x]/g, function(c) {
  var r = upper ? (HEAPU8[(((uu) + (i)) >>> 0) >>> 0]).toString(16).toUpperCase() : (HEAPU8[(((uu) + (i)) >>> 0) >>> 0]).toString(16);
  r = (r.length === 1) ? "0" + r : r;
  i++;
  return r;
 });
 stringToUTF8(uuid, out, 37);
}

I noticed that when I compiled using version 3.1.37, the correct function signature includes the upper parameter:

function _uuid_unparse(uu, out, upper) {
 var i = 0;
 var uuid = "xxxx-xx-xx-xx-xxxxxx".replace(/[x]/g, function(c) {
  var r = upper ? HEAPU8[uu + i >>> 0].toString(16).toUpperCase() : HEAPU8[uu + i >>> 0].toString(16);
  r = r.length === 1 ? "0" + r : r;
  i++;
  return r;
 });
 stringToUTF8(uuid, out, 37);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions