From: Josh Cheek Date: 2013-01-08T12:46:12+09:00 Subject: How to identify whether a line of code will return? --e89a8f2345b3c12aba04d2beb6f9 Content-Type: text/plain; charset=ISO-8859-1 Hi, I want to be able to identify whether a line of code will return, because I want to modify it to capture it's return value. If it returns, this results in a syntax error: $ echo 'def m() a = return end' | ruby -c -:1: void value expression $ echo $? 1 Here are some tests: https://github.com/JoshCheek/seeing_is_believing/blob/54f4044e1c858777f8b0beb690b9dafa9d497106/spec/syntax_analyzer_spec.rb#L114-126 Here is what I tried (hooking into `on_kw "return"` callback in Ripper): https://github.com/JoshCheek/seeing_is_believing/blob/54f4044e1c858777f8b0beb690b9dafa9d497106/lib/seeing_is_believing/syntax_analyzer.rb#L123-138 --e89a8f2345b3c12aba04d2beb6f9 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, I want to be able to identify whether a line of code will return, becau= se I want to modify it to capture it's return value. If it returns, thi= s results in a syntax error:

$ echo 'def m= () a =3D return end' | ruby -c
-:1: void value expression

$= echo $?
1


Here are= some tests:
https://github.com/JoshCheek/seeing_is_believing/blob/54f= 4044e1c858777f8b0beb690b9dafa9d497106/spec/syntax_analyzer_spec.rb#L114-126=

Here is what I tried (hooking into `on_kw "return&= quot;` callback in Ripper):
https://github.com/JoshCheek= /seeing_is_believing/blob/54f4044e1c858777f8b0beb690b9dafa9d497106/lib/seei= ng_is_believing/syntax_analyzer.rb#L123-138
--e89a8f2345b3c12aba04d2beb6f9--