parser 2.2.0.pre.2 → 2.2.0.pre.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7904839f6015d6a616f8b09ccbda8bdda64642aa
4
- data.tar.gz: 34617415104be887b446c2eeaef48a9679b9674b
3
+ metadata.gz: 9fdd84e2bf0afe8d344da8823488765821b9587d
4
+ data.tar.gz: ec152fc432ac23d54613a3a525ecc383b541b937
5
5
  SHA512:
6
- metadata.gz: a18caf32936e91ac87217aad5b8d4085762c14d1f163ca79a5a08427815e62447312ea1ebadb78d0f50b13da6ea8349377e259ba99353f9f75911513aa1f3a5b
7
- data.tar.gz: 614967deaa69a24f8d7a752cd827ddf8d0d27d3c6ace0ba14a23a331ea89e877d0186e396722b50d611253cbad94b12c349d377d7592e4ffe0f9e9421c4776a3
6
+ metadata.gz: 348b7a975ec3011a255009d9d0f02942c2cfaeb5515f39648b16673a8226a60b88bd00ab2b6cc47f67bc9001e6b26ab1c28cf938854c0dcaf910dfa40eb133ab
7
+ data.tar.gz: a53e9736e8aeaf38714ddd5944d349a36104eb288190dacac123770b2d7f41cc1dc7484d8562ab1a10cc6c01beea9337ddecb591df520da93ec9df5b05db953d
@@ -1,6 +1,16 @@
1
1
  Changelog
2
2
  =========
3
3
 
4
+ v2.2.0.pre.3 (2014-06-30)
5
+ -------------------------
6
+
7
+ Features implemented:
8
+ * Raise EncodingError when source includes invalid byte sequence (Yuji Nakayama)
9
+
10
+ Bugs fixed:
11
+ * ruby{19,20,21}.y: "x def y; z do end end": save cmdarg stack to isolate command argument state from outer scope. (Peter Zotov)
12
+ * ruby{19,20,21}.y: "tap (proc do end)": allow parenthesed do-block in cmdarg. (Peter Zotov)
13
+
4
14
  v2.2.0.pre.2 (2014-06-14)
5
15
  -------------------------
6
16
 
@@ -931,13 +931,20 @@ rule
931
931
  {
932
932
  result = @builder.begin_keyword(val[0], val[1], val[2])
933
933
  }
934
- | tLPAREN_ARG expr
934
+ | tLPAREN_ARG
935
+ {
936
+ result = @lexer.cmdarg.dup
937
+ @lexer.cmdarg.clear
938
+ }
939
+ expr
935
940
  {
936
941
  @lexer.state = :expr_endarg
937
942
  }
938
943
  opt_nl tRPAREN
939
944
  {
940
- result = @builder.begin(val[0], val[1], val[4])
945
+ @lexer.cmdarg = val[1]
946
+
947
+ result = @builder.begin(val[0], val[2], val[5])
941
948
  }
942
949
  | tLPAREN compstmt tRPAREN
943
950
  {
@@ -1084,6 +1091,7 @@ rule
1084
1091
  | kCLASS cpath superclass
1085
1092
  {
1086
1093
  @static_env.extend_static
1094
+ @lexer.push_cmdarg
1087
1095
  }
1088
1096
  bodystmt kEND
1089
1097
  {
@@ -1096,6 +1104,7 @@ rule
1096
1104
  lt_t, superclass,
1097
1105
  val[4], val[5])
1098
1106
 
1107
+ @lexer.pop_cmdarg
1099
1108
  @static_env.unextend
1100
1109
  }
1101
1110
  | kCLASS tLSHFT expr term
@@ -1104,12 +1113,14 @@ rule
1104
1113
  @def_level = 0
1105
1114
 
1106
1115
  @static_env.extend_static
1116
+ @lexer.push_cmdarg
1107
1117
  }
1108
1118
  bodystmt kEND
1109
1119
  {
1110
1120
  result = @builder.def_sclass(val[0], val[1], val[2],
1111
1121
  val[5], val[6])
1112
1122
 
1123
+ @lexer.pop_cmdarg
1113
1124
  @static_env.unextend
1114
1125
 
1115
1126
  @def_level = val[4]
@@ -1117,6 +1128,7 @@ rule
1117
1128
  | kMODULE cpath
1118
1129
  {
1119
1130
  @static_env.extend_static
1131
+ @lexer.push_cmdarg
1120
1132
  }
1121
1133
  bodystmt kEND
1122
1134
  {
@@ -1127,18 +1139,21 @@ rule
1127
1139
  result = @builder.def_module(val[0], val[1],
1128
1140
  val[3], val[4])
1129
1141
 
1142
+ @lexer.pop_cmdarg
1130
1143
  @static_env.unextend
1131
1144
  }
1132
1145
  | kDEF fname
1133
1146
  {
1134
1147
  @def_level += 1
1135
1148
  @static_env.extend_static
1149
+ @lexer.push_cmdarg
1136
1150
  }
1137
1151
  f_arglist bodystmt kEND
1138
1152
  {
1139
1153
  result = @builder.def_method(val[0], val[1],
1140
1154
  val[3], val[4], val[5])
1141
1155
 
1156
+ @lexer.pop_cmdarg
1142
1157
  @static_env.unextend
1143
1158
  @def_level -= 1
1144
1159
  }
@@ -1150,12 +1165,14 @@ rule
1150
1165
  {
1151
1166
  @def_level += 1
1152
1167
  @static_env.extend_static
1168
+ @lexer.push_cmdarg
1153
1169
  }
1154
1170
  f_arglist bodystmt kEND
1155
1171
  {
1156
1172
  result = @builder.def_singleton(val[0], val[1], val[2],
1157
1173
  val[4], val[6], val[7], val[8])
1158
1174
 
1175
+ @lexer.pop_cmdarg
1159
1176
  @static_env.unextend
1160
1177
  @def_level -= 1
1161
1178
  }
@@ -951,13 +951,20 @@ rule
951
951
 
952
952
  result = @builder.begin_keyword(val[0], val[2], val[3])
953
953
  }
954
- | tLPAREN_ARG expr
954
+ | tLPAREN_ARG
955
+ {
956
+ result = @lexer.cmdarg.dup
957
+ @lexer.cmdarg.clear
958
+ }
959
+ expr
955
960
  {
956
961
  @lexer.state = :expr_endarg
957
962
  }
958
963
  opt_nl tRPAREN
959
964
  {
960
- result = @builder.begin(val[0], val[1], val[4])
965
+ @lexer.cmdarg = val[1]
966
+
967
+ result = @builder.begin(val[0], val[2], val[5])
961
968
  }
962
969
  | tLPAREN_ARG
963
970
  {
@@ -1112,6 +1119,7 @@ rule
1112
1119
  | kCLASS cpath superclass
1113
1120
  {
1114
1121
  @static_env.extend_static
1122
+ @lexer.push_cmdarg
1115
1123
  }
1116
1124
  bodystmt kEND
1117
1125
  {
@@ -1124,6 +1132,7 @@ rule
1124
1132
  lt_t, superclass,
1125
1133
  val[4], val[5])
1126
1134
 
1135
+ @lexer.pop_cmdarg
1127
1136
  @static_env.unextend
1128
1137
  }
1129
1138
  | kCLASS tLSHFT expr term
@@ -1132,12 +1141,14 @@ rule
1132
1141
  @def_level = 0
1133
1142
 
1134
1143
  @static_env.extend_static
1144
+ @lexer.push_cmdarg
1135
1145
  }
1136
1146
  bodystmt kEND
1137
1147
  {
1138
1148
  result = @builder.def_sclass(val[0], val[1], val[2],
1139
1149
  val[5], val[6])
1140
1150
 
1151
+ @lexer.pop_cmdarg
1141
1152
  @static_env.unextend
1142
1153
 
1143
1154
  @def_level = val[4]
@@ -1145,6 +1156,7 @@ rule
1145
1156
  | kMODULE cpath
1146
1157
  {
1147
1158
  @static_env.extend_static
1159
+ @lexer.push_cmdarg
1148
1160
  }
1149
1161
  bodystmt kEND
1150
1162
  {
@@ -1155,18 +1167,21 @@ rule
1155
1167
  result = @builder.def_module(val[0], val[1],
1156
1168
  val[3], val[4])
1157
1169
 
1170
+ @lexer.pop_cmdarg
1158
1171
  @static_env.unextend
1159
1172
  }
1160
1173
  | kDEF fname
1161
1174
  {
1162
1175
  @def_level += 1
1163
1176
  @static_env.extend_static
1177
+ @lexer.push_cmdarg
1164
1178
  }
1165
1179
  f_arglist bodystmt kEND
1166
1180
  {
1167
1181
  result = @builder.def_method(val[0], val[1],
1168
1182
  val[3], val[4], val[5])
1169
1183
 
1184
+ @lexer.pop_cmdarg
1170
1185
  @static_env.unextend
1171
1186
  @def_level -= 1
1172
1187
  }
@@ -1178,12 +1193,14 @@ rule
1178
1193
  {
1179
1194
  @def_level += 1
1180
1195
  @static_env.extend_static
1196
+ @lexer.push_cmdarg
1181
1197
  }
1182
1198
  f_arglist bodystmt kEND
1183
1199
  {
1184
1200
  result = @builder.def_singleton(val[0], val[1], val[2],
1185
1201
  val[4], val[6], val[7], val[8])
1186
1202
 
1203
+ @lexer.pop_cmdarg
1187
1204
  @static_env.unextend
1188
1205
  @def_level -= 1
1189
1206
  }
@@ -941,13 +941,20 @@ rule
941
941
 
942
942
  result = @builder.begin_keyword(val[0], val[2], val[3])
943
943
  }
944
- | tLPAREN_ARG expr
944
+ | tLPAREN_ARG
945
+ {
946
+ result = @lexer.cmdarg.dup
947
+ @lexer.cmdarg.clear
948
+ }
949
+ expr
945
950
  {
946
951
  @lexer.state = :expr_endarg
947
952
  }
948
953
  opt_nl tRPAREN
949
954
  {
950
- result = @builder.begin(val[0], val[1], val[4])
955
+ @lexer.cmdarg = val[1]
956
+
957
+ result = @builder.begin(val[0], val[2], val[5])
951
958
  }
952
959
  | tLPAREN_ARG
953
960
  {
@@ -1102,6 +1109,7 @@ rule
1102
1109
  | kCLASS cpath superclass
1103
1110
  {
1104
1111
  @static_env.extend_static
1112
+ @lexer.push_cmdarg
1105
1113
  }
1106
1114
  bodystmt kEND
1107
1115
  {
@@ -1114,6 +1122,7 @@ rule
1114
1122
  lt_t, superclass,
1115
1123
  val[4], val[5])
1116
1124
 
1125
+ @lexer.pop_cmdarg
1117
1126
  @static_env.unextend
1118
1127
  }
1119
1128
  | kCLASS tLSHFT expr term
@@ -1122,12 +1131,14 @@ rule
1122
1131
  @def_level = 0
1123
1132
 
1124
1133
  @static_env.extend_static
1134
+ @lexer.push_cmdarg
1125
1135
  }
1126
1136
  bodystmt kEND
1127
1137
  {
1128
1138
  result = @builder.def_sclass(val[0], val[1], val[2],
1129
1139
  val[5], val[6])
1130
1140
 
1141
+ @lexer.pop_cmdarg
1131
1142
  @static_env.unextend
1132
1143
 
1133
1144
  @def_level = val[4]
@@ -1135,6 +1146,7 @@ rule
1135
1146
  | kMODULE cpath
1136
1147
  {
1137
1148
  @static_env.extend_static
1149
+ @lexer.push_cmdarg
1138
1150
  }
1139
1151
  bodystmt kEND
1140
1152
  {
@@ -1145,18 +1157,21 @@ rule
1145
1157
  result = @builder.def_module(val[0], val[1],
1146
1158
  val[3], val[4])
1147
1159
 
1160
+ @lexer.pop_cmdarg
1148
1161
  @static_env.unextend
1149
1162
  }
1150
1163
  | kDEF fname
1151
1164
  {
1152
1165
  @def_level += 1
1153
1166
  @static_env.extend_static
1167
+ @lexer.push_cmdarg
1154
1168
  }
1155
1169
  f_arglist bodystmt kEND
1156
1170
  {
1157
1171
  result = @builder.def_method(val[0], val[1],
1158
1172
  val[3], val[4], val[5])
1159
1173
 
1174
+ @lexer.pop_cmdarg
1160
1175
  @static_env.unextend
1161
1176
  @def_level -= 1
1162
1177
  }
@@ -1168,12 +1183,14 @@ rule
1168
1183
  {
1169
1184
  @def_level += 1
1170
1185
  @static_env.extend_static
1186
+ @lexer.push_cmdarg
1171
1187
  }
1172
1188
  f_arglist bodystmt kEND
1173
1189
  {
1174
1190
  result = @builder.def_singleton(val[0], val[1], val[2],
1175
1191
  val[4], val[6], val[7], val[8])
1176
1192
 
1193
+ @lexer.pop_cmdarg
1177
1194
  @static_env.unextend
1178
1195
  @def_level -= 1
1179
1196
  }
@@ -145,12 +145,17 @@ module Parser
145
145
  #
146
146
  # @param [String] input
147
147
  # @raise [ArgumentError] if already populated
148
+ # @raise [EncodingError] if `input` includes invalid byte sequence for the encoding
148
149
  # @return [String]
149
150
  #
150
151
  def source=(input)
151
152
  if defined?(Encoding)
152
153
  input = input.dup if input.frozen?
153
154
  input = self.class.reencode_string(input)
155
+
156
+ unless input.valid_encoding?
157
+ raise EncodingError, "invalid byte sequence in #{input.encoding.name}"
158
+ end
154
159
  end
155
160
 
156
161
  self.raw_source = input
@@ -1,3 +1,3 @@
1
1
  module Parser
2
- VERSION = '2.2.0.pre.2'
2
+ VERSION = '2.2.0.pre.3'
3
3
  end
@@ -10,9 +10,11 @@ class TestDiagnostic < Minitest::Test
10
10
  end
11
11
 
12
12
  def test_verifies_levels
13
- assert_raises ArgumentError, /level/ do
14
- Parser::Diagnostic.new(:foobar, :escape_eof, @range1)
13
+ error = assert_raises ArgumentError do
14
+ Parser::Diagnostic.new(:foobar, :escape_eof, {}, @range1)
15
15
  end
16
+
17
+ assert_match /level/, error.message
16
18
  end
17
19
 
18
20
  def test_freezes
@@ -32,7 +32,7 @@ class TestDiagnosticEngine < Minitest::Test
32
32
 
33
33
  error = Parser::Diagnostic.new(:error, :invalid_escape, @buffer, 1..2)
34
34
 
35
- err = assert_raises Parser::SyntaxError, error.message do
35
+ err = assert_raises Parser::SyntaxError do
36
36
  @engine.process(error)
37
37
  end
38
38
 
@@ -4796,7 +4796,7 @@ class TestParser < Minitest::Test
4796
4796
  nil))),
4797
4797
  %q{bar def foo; self.each do end end},
4798
4798
  %q{},
4799
- ALL_VERSIONS - %w(1.8 1.9 2.0 2.1))
4799
+ ALL_VERSIONS - %w(1.8))
4800
4800
  end
4801
4801
 
4802
4802
  def test_bug_do_block_in_cmdarg
@@ -4809,7 +4809,7 @@ class TestParser < Minitest::Test
4809
4809
  s(:args), nil))),
4810
4810
  %q{tap (proc do end)},
4811
4811
  %q{},
4812
- ALL_VERSIONS - %w(1.8 1.9 2.0 2.1))
4812
+ ALL_VERSIONS - %w(1.8))
4813
4813
  end
4814
4814
 
4815
4815
  def test_bug_interp_single
@@ -29,6 +29,19 @@ class TestSourceBuffer < Minitest::Test
29
29
  end
30
30
  end
31
31
 
32
+ if defined?(Encoding)
33
+ def test_source_setter_encoding_error
34
+ error = assert_raises EncodingError do
35
+ @buffer.source = [
36
+ '# encoding: utf-8',
37
+ "# \xf9"
38
+ ].join("\n")
39
+ end
40
+
41
+ assert_match /invalid byte sequence in UTF\-8/, error.message
42
+ end
43
+ end
44
+
32
45
  def test_read
33
46
  tempfile = Tempfile.new('parser')
34
47
  tempfile.write('foobar')
@@ -157,20 +157,24 @@ class TestSourceRewriter < Minitest::Test
157
157
  end
158
158
 
159
159
  def test_nested_transaction_raises_error
160
- assert_raises RuntimeError, /nested/ do
160
+ error = assert_raises RuntimeError do
161
161
  @rewriter.transaction do
162
162
  @rewriter.transaction do
163
163
  end
164
164
  end
165
165
  end
166
+
167
+ assert_match /nested/i, error.message
166
168
  end
167
169
 
168
170
  def test_process_in_transaction_raises_error
169
- assert_raises RuntimeError, /transaction/ do
171
+ error = assert_raises RuntimeError do
170
172
  @rewriter.transaction do
171
173
  @rewriter.process
172
174
  end
173
175
  end
176
+
177
+ assert_match /transaction/, error.message
174
178
  end
175
179
 
176
180
  def silence_diagnostics
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0.pre.2
4
+ version: 2.2.0.pre.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Zotov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-14 00:00:00.000000000 Z
11
+ date: 2014-07-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast