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
I recently upgraded miniMAL to use a more recent version of RegPack and while most of the source fils pack/unpack correctly, I discovered a case where the unpacked source is wrong. This happened with the options --crushGainFactor 2 --crushLengthFactor 1 --crushCopiesFactor 0. For this same file, using 1, 0, 0 fixes the problem. However, there might be source files for which 1, 0, 0 also displays this problem so it's not obvious to me that the 2, 1, 0 options are where the problem lies or just revealing a deeper issue.
Here is input source that triggers the problem:
module.exports=function(n){functione(n,e){for(;ninstanceofArray&&n[0]ine&&e[n[0]].M;)n=e[n[0]](...n.slice(1));returnn}functiont(n,r){for(;;){if(!(ninstanceofArray))returni(n,r);if(n=e(n,r),!(ninstanceofArray))returni(n,r);if("def"==n[0])returnr[n[1]]=t(n[2],r);if("~"==n[0]){lete=t(n[1],r);returne.M=1,e}if("`"==n[0])returnn[1];if(".-"==n[0]){lete=i(n.slice(1),r),t=e[0][e[1]];return2ine?e[0][e[1]]=e[2]:t}if("."==n[0]){lete=i(n.slice(1),r),t=e[0][e[1]];returnt.apply(e[0],e.slice(2))}if("try"==n[0])try{returnt(n[1],r)}catch(e){returnt(n[2][2],i([n[2][1]],r,[e]))}elseif("fn"==n[0]){lete=function(...e){returnt(n[2],i(n[1],r,e))};returne.A=[n[2],r,n[1]],e}if("let"==n[0]){r=Object.create(r);for(leteinn[1])e%2&&(r[n[1][e-1]]=t(n[1][e],r));n=n[2]}elseif("do"==n[0]){lete=i(n.slice(1,n.length-1),r);n=n[n.length-1]}elseif("if"==n[0])n=t(n[1],r)?n[2]:n[3];else{lete=i(n,r),t=e[0];if(!t.A)returnt(...e.slice(1));n=t.A[0],r=i(t.A[2],t.A[1],e.slice(1))}}}leti=function(e,i,r){returnr?(i=Object.create(i),e.some((n,t)=>"&"==n?i[e[t+1]]=r.slice(t):(i[n]=r[t],0)),i):einstanceofArray?e.map((...n)=>t(n[0],i)):typeof""==typeofe?eini?i[e]:n.throw(e+" not found"):e};returnn=Object.assign(Object.create(n),{js:eval,eval:(...e)=>t(e[0],n),"=":(...n)=>n[0]===n[1],"<":(...n)=>n[0]<n[1],"+":(...n)=>n[0]+n[1],"-":(...n)=>n[0]-n[1],"*":(...n)=>n[0]*n[1],"/":(...n)=>n[0]/n[1],isa:(...n)=>n[0]instanceofn[1],type:(...n)=>typeofn[0],new:(...n)=>new(n[0].bind(...n)),del:(...n)=>deleten[0][n[1]],throw:(...n)=>{thrown[0]},read:(...n)=>JSON.parse(n[0]),slurp:(...n)=>require("fs").readFileSync(n[0],"utf8"),load:(...e)=>t(JSON.parse(require("fs").readFileSync(e[0],"utf8")),n),rep:(...e)=>JSON.stringify(t(JSON.parse(e[0]),n))})}
Running the resulting regpack with node results in the following error:
undefined:1
module.exports=function(n){function e(n,e){for(;n stanceof Array&&n[0] e&&e[n[0]].M;)n=e[n[0]](...n.slice(1));return n}function t(n,r){for(;;){if(!(n stanceof Array))return i(n,r);if(n=e(n,r),!(n stanceof Array))return i(n,r);if("def"==n[0])return r[n[1]]=t(n[2],r);if("~"==n[0]){let e=t(n[1],r);return e.M=1,e}if("`"==n[0])return n[1];if(".-"==n[0]){let e=i(n.slice(1),r),t=e[0][e[1]];return 2 e?e[0][e[1]]=e[2]:t}if("."==n[0]){let e=i(n.slice(1),r),t=e[0][e[1]];return t.apply(e[0],e.slice(2))}if("try"==n[0])try{return t(n[1],r)}catch(e){return t(n[2][2]in,i([n[2][1]],r,[e]))}else if("fn"==n[0]){let e=function(...e){return t(n[2]in,i(n[1],r,e))};return e.A=[n[2],r,n[1]],e}if("let"==n[0]){r=Object.create(r);for(let e n[1])e%2&&(r[n[1][e-1]]=t(n[1][e],r));n=n[2]}else if("do"==n[0]){let e=i(n.slice(1,n.length-1),r);n=n[n.length-1]}else if("if"==n[0])n=t(n[1],r)?n[2]:n[3];else{let e=i(n,r),t=e[0];if(!t.A)return t(...e.slice(1));n=t.A[0],r=i(t.A[2],t.A[1],e.slice(1))}}}let i=function(ein,i,r){return r
SyntaxError: Unexpected identifier
at Object.<anonymous> (/data/joelm/personal/programming/miniMAL/js/blah-regpack.js:11:6)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.runMain (module.js:605:10)
at run (bootstrap_node.js:420:7)
at startup (bootstrap_node.js:139:9)
at bootstrap_node.js:535:3
I printed out the source code after unpacking (right before the final eval) and got this:
This is almost the original source before packing but not quite. The differences are:
Missing all of the original 11 occurrences of the string "in". You can easily see the first missing position if you scan across to "n stanceof" which should have been "n instanceof".
5 occurrences of the string "in" in places in the code where it shouldn't be. All of these extra "in" strings occur before commas and all but one appear after a right bracket. I'm not sure if that's relevant for tracking down the bug or not.
The text was updated successfully, but these errors were encountered:
Most likely the same issue as #65 . I was able to repeat the issue, and the log mentions the faulty token \ matching the original string in. Let me fix it then confirm by testing with your code.
I recently upgraded miniMAL to use a more recent version of RegPack and while most of the source fils pack/unpack correctly, I discovered a case where the unpacked source is wrong. This happened with the options
--crushGainFactor 2 --crushLengthFactor 1 --crushCopiesFactor 0
. For this same file, using 1, 0, 0 fixes the problem. However, there might be source files for which 1, 0, 0 also displays this problem so it's not obvious to me that the 2, 1, 0 options are where the problem lies or just revealing a deeper issue.Here is input source that triggers the problem:
Running the resulting regpack with node results in the following error:
I printed out the source code after unpacking (right before the final eval) and got this:
This is almost the original source before packing but not quite. The differences are:
The text was updated successfully, but these errors were encountered: