aboutsummaryrefslogtreecommitdiff
path: root/build2/parser.cxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-10-20 14:03:05 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-11-04 09:26:33 +0200
commit78406602be0ce392224dd3735ad9a9442df572f7 (patch)
tree3cda9698251f566d5685fe707220d3cbeec3af0e /build2/parser.cxx
parent53d649dec4c98c9f08b963ed913685a83d68e7e1 (diff)
When assigning always ignore existing value type
For example: x = [uint64] 1 x = a # Ok.
Diffstat (limited to 'build2/parser.cxx')
-rw-r--r--build2/parser.cxx42
1 files changed, 22 insertions, 20 deletions
diff --git a/build2/parser.cxx b/build2/parser.cxx
index 1ecf808..dfe85be 100644
--- a/build2/parser.cxx
+++ b/build2/parser.cxx
@@ -1594,31 +1594,33 @@ namespace build2
// be the same. Also check that the requested value type doesn't conflict
// with the variable type.
//
- if (type != nullptr)
+ if (type != nullptr &&
+ var != nullptr &&
+ var->type != nullptr &&
+ var->type != type)
{
- if (var != nullptr && var->type != nullptr && var->type != type)
- fail (l) << "conflicting variable " << var->name << " type "
- << var->type->name << " and value type " << type->name;
+ fail (l) << "conflicting variable " << var->name << " type "
+ << var->type->name << " and value type " << type->name;
+ }
- if (kind == type::assign)
- {
- if (type != v.type)
- {
- v = nullptr; // Clear old value.
- v.type = type;
- }
- }
- else
+ if (kind == type::assign)
+ {
+ if (type != v.type)
{
- if (!v)
- v.type = type;
- else if (v.type == nullptr)
- typify (v, *type, var);
- else if (v.type != type)
- fail (l) << "conflicting original value type " << v.type->name
- << " and append/prepend value type " << type->name;
+ v = nullptr; // Clear old value.
+ v.type = type;
}
}
+ else if (type != nullptr)
+ {
+ if (!v)
+ v.type = type;
+ else if (v.type == nullptr)
+ typify (v, *type, var);
+ else if (v.type != type)
+ fail (l) << "conflicting original value type " << v.type->name
+ << " and append/prepend value type " << type->name;
+ }
if (null)
{