Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
d1bea8ac
Commit
d1bea8ac
authored
Jul 16, 2014
by
Maxime Perrotin
Browse files
Added bound test in primary_substring
parent
4b8618fd
Changes
1
Hide whitespace changes
Inline
Side-by-side
ogParser.py
View file @
d1bea8ac
...
...
@@ -1386,6 +1386,20 @@ def primary_substring(root, context):
if
receiver_bty
.
kind
==
'SequenceOfType'
or
\
receiver_bty
.
kind
.
endswith
(
'StringType'
):
node
.
exprType
=
receiver
.
exprType
# Check bounds
basic
=
find_basic_type
(
node
.
exprType
)
min0
=
find_basic_type
(
params
[
0
].
exprType
).
Min
min1
=
find_basic_type
(
params
[
1
].
exprType
).
Min
max0
=
find_basic_type
(
params
[
0
].
exprType
).
Max
max1
=
find_basic_type
(
params
[
1
].
exprType
).
Max
if
int
(
min0
)
>
int
(
min1
)
or
int
(
max0
)
>
int
(
max1
):
msg
=
'Substring bounds are invalid'
errors
.
append
(
error
(
root
,
msg
))
if
int
(
min0
)
>
int
(
basic
.
Max
)
\
or
int
(
max1
)
>
int
(
basic
.
Max
):
msg
=
'Substring bounds [{}..{}] outside range [{}..{}]'
.
format
(
min0
,
max1
,
basic
.
Min
,
basic
.
Max
)
errors
.
append
(
error
(
root
,
msg
))
else
:
msg
=
'Element {} cannot have a substring'
.
format
(
receiver
)
errors
.
append
(
error
(
root
,
msg
))
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment