#36 Inlining of ifNil:ifNotNil: messed up returns

已關閉
nero8 年之前創建 · 0 條評論

Originally at 2011-09-05T23:25:24Z by Göran Krampe closed at 2012-05-08T15:55:45Z

Ok, so this works:

nil ifNil: [1] ifNotNil: [2]

...but not this:

^nil ifNil: [1] ifNotNil: [2]

It says "SyntaxError: Missing catch or finally after try" and the code generated looks like this:

smalltalk.method({ selector: "doIt", source: unescape("doIt%20%5E%5B%5Enil%20ifNil%3A%20%5B1%5D%20ifNotNil%3A%20%5B2%5D%5D%20value"), fn: function(){ var self=this; try{return smalltalk.send((function(){return (function(){throw({name: 'stReturn', selector: '_doIt', fn: function(){return (($receiver = nil) == nil || $receiver == undefined) ? (function(){return (1);})() : (function(){return (2);})()}})})();}), "_value", [])}})})(); return self; } catch(e) {if(e.name === 'stReturn' && e.selector === '_doIt'){return e.fn()} throw(e)}}, messageSends: ["value", "ifNil:ifNotNil:"], referencedClasses: []})

...now, perhaps some nesting wrong? Not sure.

Originally at 2011-09-05T23:25:24Z by Göran Krampe closed at 2012-05-08T15:55:45Z Ok, so this works: nil ifNil: [1] ifNotNil: [2] ...but not this: ^nil ifNil: [1] ifNotNil: [2] It says "SyntaxError: Missing catch or finally after try" and the code generated looks like this: smalltalk.method({ selector: "doIt", source: unescape("doIt%20%5E%5B%5Enil%20ifNil%3A%20%5B1%5D%20ifNotNil%3A%20%5B2%5D%5D%20value"), fn: function(){ var self=this; try{return smalltalk.send((function(){return (function(){throw({name: 'stReturn', selector: '_doIt', fn: function(){return (($receiver = nil) == nil || $receiver == undefined) ? (function(){return (1);})() : (function(){return (2);})()}})})();}), "_value", [])}})})(); return self; } catch(e) {if(e.name === 'stReturn' && e.selector === '_doIt'){return e.fn()} throw(e)}}, messageSends: ["value", "ifNil:ifNotNil:"], referencedClasses: []}) ...now, perhaps some nesting wrong? Not sure.
nero7 年之前 關閉
登入 才能加入這對話。
未選擇標籤
未選擇里程碑
未指派成員
1 參與者
正在加載...
取消
保存
尚未有任何內容