You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Updating from .14 -> .15, code with using fails in strict mode with ReferenceError: resource is not defined.
This is the generated _using_ctx():
function_using_ctx(){var_disposeSuppressedError=typeofSuppressedError==="function" ? SuppressedError : function(error,suppressed){varerr=newError();err.name="SuppressedError";err.suppressed=suppressed;err.error=error;returnerr;},empty={},stack=[];functionusing(isAwait,value){if(value!=null){if(Object(value)!==value){thrownewTypeError("using declarations can only be used with objects, functions, null, or undefined.");}if(isAwait){vardispose=value[Symbol.asyncDispose||Symbol.for("Symbol.asyncDispose")];}if(dispose==null){dispose=value[Symbol.dispose||Symbol.for("Symbol.dispose")];}if(typeofdispose!=="function"){thrownewTypeError(`Property [Symbol.dispose] is not a function.`);}stack.push({v: value,d: dispose,a: isAwait});}elseif(isAwait){stack.push({d: value,a: isAwait});}returnvalue;}return{e: empty,u: using.bind(null,false),a: using.bind(null,true),d: function(){varerror=this.e;functionnext(){while(resource=stack.pop()){// ^^^^^ fails heretry{varresource1,disposalResult=resource1.d&&resource1.d.call(resource1.v);if(resource1.a){returnPromise.resolve(disposalResult).then(next,err);}}catch(e){returnerr(e);}}if(error!==empty)throwerror;}functionerr(e){error=error!==empty ? new_disposeSuppressedError(error,e) : e;returnnext();}returnnext();}};
jeengbe
changed the title
Regression in v1.4.15: ReferenceError: resource is not defined with using code
Regression in v1.4.15: ReferenceError: resource is not defined in strict mode
Apr 17, 2024
This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.
Describe the bug
Updating from
.14
->.15
, code withusing
fails in strict mode withReferenceError: resource is not defined
.This is the generated
_using_ctx()
:The test is run in strict mode.
Input code
No response
Config
Playground link (or link to the minimal reproduction)
https://play.swc.rs/?version=1.4.15&code=H4sIAAAAAAAAAystzsxLV6hQsFUoy89MUTCwBgAGGiiaEQAAAA%3D%3D&config=H4sIAAAAAAAAA1WPSw7DIAwF9zkF8rrbdtE79BCIOhERP9mOVBTl7oUE0maH3xszsA5KwcwGnmotxzIkTYx0ziXhHER%2FSgKSE7IhmwRuvRWu1agd4x5tRwOiaUKpW8j3hoOLkbHjLfM22DH%2FC030iZD5ClZUh8nhVTc0Jfj4XvayfaQ%2B9tA%2F4Ad12XkxWH71TaEFh%2B0LYuVI0xQBAAA%3D
Note that the produced code has to be run in strict mode.
SWC Info output
No response
Expected behavior
n/a
Actual behavior
No response
Version
1.4.15
Additional context
This change broke it: #8860
The text was updated successfully, but these errors were encountered: