From 46447667f19657a100ccdc998f258ca13287329a Mon Sep 17 00:00:00 2001 From: yui-knk Date: Sat, 20 Oct 2018 10:10:46 +0000 Subject: [PATCH] Fix locations of NODE_LAMBDA. * node.h: Add `nd_first_loc` and `nd_set_first_loc` * parse.y: Fix to start with the beginning of `->` . e.g. The locations of the NODE_LAMBDA is fixed: ``` -> x { 1 + 2 } ``` * Before ``` NODE_LAMBDA (line: 1, location: (1,2)-(1,14)) ``` * After ``` NODE_LAMBDA (line: 1, location: (1,0)-(1,14)) ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@65221 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- node.h | 2 ++ parse.y | 3 +++ 2 files changed, 5 insertions(+) diff --git a/node.h b/node.h index 334c221f2d..f725a38df4 100644 --- a/node.h +++ b/node.h @@ -192,6 +192,8 @@ typedef struct RNode { #define nd_set_first_column(n, v) ((n)->nd_loc.beg_pos.column = (v)) #define nd_first_lineno(n) ((int)((n)->nd_loc.beg_pos.lineno)) #define nd_set_first_lineno(n, v) ((n)->nd_loc.beg_pos.lineno = (v)) +#define nd_first_loc(n) ((n)->nd_loc.beg_pos) +#define nd_set_first_loc(n, v) (nd_first_loc(n) = (v)) #define nd_last_column(n) ((int)((n)->nd_loc.end_pos.column)) #define nd_set_last_column(n, v) ((n)->nd_loc.end_pos.column = (v)) diff --git a/parse.y b/parse.y index 9cb94fd644..431ad0118d 100644 --- a/parse.y +++ b/parse.y @@ -2443,6 +2443,9 @@ primary : literal lambda { $$ = $3; + /*%%%*/ + nd_set_first_loc($$, @1.beg_pos); + /*% %*/ } | k_if expr_value then compstmt