#36 Inlining of ifNil:ifNotNil: messed up returns

Đã đóng
%! (template.HTML=8 năm trước cách đây)đang mở bởi nero · 0 ý kiến

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.
Đăng nhập để tham gia bình luận.
Không có nhãn
Không có Milestone
Không có người được phân công
1 tham gia
Đang tải...
Hủy bỏ
Lưu
Ở đây vẫn chưa có nội dung nào.