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'] = {
...
@@ -175,28 +175,24 @@ Blockly.Blocks['variables_set'] = {
var
varName
=
this
.
getFieldValue
(
'
VAR
'
);
var
varName
=
this
.
getFieldValue
(
'
VAR
'
);
// Check what this block type should be
// 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
// Check if variable has been defined already
var
unique
=
true
;
var
varType
=
Blockly
.
StaticTyping
.
findListVarType
(
varName
,
existingVars
);
for
(
var
name
in
existingVars
)
{
if
(
varType
===
null
)
{
if
(
name
==
varName
)
{
// This block var has not been encountered before, so return type
unique
=
false
;
break
;
}
}
// Only set the type if the variable has not been defined before
if
(
unique
)
{
this
.
setWarningText
(
null
);
this
.
setWarningText
(
null
);
return
varType
;
return
thisBlockType
;
}
else
if
(
(
existingVars
[
varName
]
!=
varType
)
&&
}
else
if
((
existingVars
[
varName
]
!==
thisBlockType
)
&&
(
this
.
getChildren
().
length
==
0
)
)
{
(
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
'
+
this
.
setWarningText
(
'
This block is using a different type than what
'
+
'
was set on the first use of this variable.
\n
First use type:
'
+
'
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
;
return
null
;
}
else
{
}
else
{
// Variable defined before, but it is the same type, or block is empty
this
.
setWarningText
(
null
);
this
.
setWarningText
(
null
);
return
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