Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ardublockly
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
xpstem
ardublockly
Commits
bb5f52a4
Commit
bb5f52a4
authored
Feb 27, 2015
by
carlosperate
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix issue with variables not recognising variable type change correctly.
parent
1fc41c44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
15 deletions
+11
-15
blocks/variables.js
blocks/variables.js
+11
-15
No files found.
blocks/variables.js
View file @
bb5f52a4
...
...
@@ -175,28 +175,24 @@ Blockly.Blocks['variables_set'] = {
var
varName
=
this
.
getFieldValue
(
'
VAR
'
);
// Check what this block type should be
var
var
Type
=
Blockly
.
StaticTyping
.
getChildBlockType
(
this
);
var
thisBlock
Type
=
Blockly
.
StaticTyping
.
getChildBlockType
(
this
);
// Check if variable has been defined already
var
unique
=
true
;
for
(
var
name
in
existingVars
)
{
if
(
name
==
varName
)
{
unique
=
false
;
break
;
}
}
// Only set the type if the variable has not been defined before
if
(
unique
)
{
var
varType
=
Blockly
.
StaticTyping
.
findListVarType
(
varName
,
existingVars
);
if
(
varType
===
null
)
{
// This block var has not been encountered before, so return type
this
.
setWarningText
(
null
);
return
varType
;
}
else
if
(
(
existingVars
[
varName
]
!=
varType
)
&&
(
this
.
getChildren
().
length
==
0
)
)
{
return
thisBlockType
;
}
else
if
((
existingVars
[
varName
]
!==
thisBlockType
)
&&
(
this
.
getChildren
().
length
>
0
))
{
// Variable name defined before, but only set warning if there are child
// blocks
this
.
setWarningText
(
'
This block is using a different type than what
'
+
'
was set on the first use of this variable.
\n
First use type:
'
+
existingVars
[
varName
]
+
'
\n
This block type:
'
+
var
Type
);
existingVars
[
varName
]
+
'
\n
This block type:
'
+
thisBlock
Type
);
return
null
;
}
else
{
// Variable defined before, but it is the same type, or block is empty
this
.
setWarningText
(
null
);
return
null
;
}
...
...
Write
Preview
Markdown
is supported
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