Commit 0def3517 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Accept numerical types with MIN/MAX

parent 8ef2596a
......@@ -777,13 +777,20 @@ def check_type_compatibility(primary, type_ref, context):
if basic_type.kind == 'StandardStringType':
return
elif basic_type.kind.endswith('StringType'):
if int(basic_type.Min) <= len(
primary.value[1:-1]) <= int(basic_type.Max):
try:
if int(basic_type.Min) <= len(
primary.value[1:-1]) <= int(basic_type.Max):
return
else:
raise TypeError('Invalid string literal'
' - check that length is'
'within the bound limits {Min}..{Max}'
.format(Min=str(basic_type.Min),
Max=str(basic_type.Max)))
except ValueError:
# No size constraint (or MIN/MAX)
LOG.debug('String literal size constraint discarded')
return
else:
raise TypeError('Invalid string literal - check that length is'
'within the bound limits {Min}..{Max}'.format
(Min=str(basic_type.Min), Max=str(basic_type.Max)))
else:
raise TypeError('String literal not expected')
elif (isinstance(primary, ogAST.PrimMantissaBaseExp) and
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment