def _translate_in(self, element, sequence, location):
sequence_node = self._translate_node(sequence)
element_node = self._translate_node(element)
if not (
sequence_node['pseudo_type'] == 'String' and element_node['pseudo_type'] == 'String' or\
isinstance(sequence_node['pseudo_type'], list) and sequence_node['pseudo_type'][0] != 'Tuple' and sequence_node['pseudo_type'][1] == element_node['pseudo_type']):
raise type_check_error('expected the left side of in to has the element type of the sequence, in supported for string and sequences which are not tuples',
location, self.lines[location[0]],
wrong_type=element_node['pseudo_type'])
return {
'type': 'standard_method_call',
'receiver': sequence_node,
'message': 'include?',
'args': [element_node],
'pseudo_type': 'Boolean'
}
评论列表
文章目录