Fix various bugs with table/set attributes.

- Identifiers that are initialized with set()/table() constructor
  expressions now inherit attributes from the expression.  Before,
  statements like

     const i: set[string] = set() &redef;

  associated the attribute with the set() constructor, but not the
  "i" identifier, preventing redefinition.  Addresses #866.

- Allow &default attribute to apply to tables initialized as empty
  (via either "{ }" or "table()") or if the expression supplied to it
  can evaluate to a type that's promotable to the same yield type as
  the table.
This commit is contained in:
Jon Siwek 2012-11-29 15:44:03 -06:00
parent 00f7bbda96
commit f7e07f5f09
6 changed files with 249 additions and 1 deletions

View file

@ -0,0 +1,91 @@
my_set_ctor_init
{
test2,
test3,
test4,
test1
}
my_table_ctor_init
{
[2] = test2,
[1] = test1,
[3] = test3
}
nope
my_set_init
{
test2,
test3,
test4,
test1
}
my_table_init
{
[2] = test2,
[4] = test4,
[1] = test1,
[3] = test3
}
nope
inception
{
[0] = {
[13] = bar
}
}
{
[13] = bar
}
bar
forty-two
{
}
we need to go deeper
{
[0] = {
[13] = bar
}
}
{
[13] = bar
}
bar
forty-two
{
}
we need to go deeper
local table t1
{
[1] = foo
}
foo
nope
local table t2
{
[1] = foo
}
foo
nope
local table t3
{
}
nope
nope
local table t4
{
}
nope
nope