[vala] codegen: Fix foreach on inline allocated arrays
- From: Luca Bruno <lucabru src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Fix foreach on inline allocated arrays
- Date: Sat, 18 Jun 2011 10:25:47 +0000 (UTC)
commit 0e9b10c1a7b612abfdc7feb5b3c71b77705144e7
Author: Luca Bruno <lucabru src gnome org>
Date: Sat Jun 18 12:21:14 2011 +0200
codegen: Fix foreach on inline allocated arrays
Fixes bug 652549.
codegen/valaccodecontrolflowmodule.vala | 3 ++-
tests/Makefile.am | 1 +
tests/control-flow/bug652549.vala | 6 ++++++
vala/valaforeachstatement.vala | 2 +-
4 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodecontrolflowmodule.vala b/codegen/valaccodecontrolflowmodule.vala
index b939bed..46c8ed1 100644
--- a/codegen/valaccodecontrolflowmodule.vala
+++ b/codegen/valaccodecontrolflowmodule.vala
@@ -222,11 +222,12 @@ public abstract class Vala.CCodeControlFlowModule : CCodeMethodModule {
ccode.open_block ();
var collection_backup = stmt.collection_variable;
- var collection_type = collection_backup.variable_type.copy ();
+ var collection_type = collection_backup.variable_type;
var array_type = collection_type as ArrayType;
if (array_type != null) {
// avoid assignment issues
+ array_type.inline_allocated = false;
array_type.fixed_length = false;
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index a4b1bed..9819401 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -47,6 +47,7 @@ TESTS = \
control-flow/foreach.vala \
control-flow/switch.vala \
control-flow/sideeffects.vala \
+ control-flow/bug652549.vala \
enums/enums.vala \
structs/structs.vala \
structs/gvalue.vala \
diff --git a/tests/control-flow/bug652549.vala b/tests/control-flow/bug652549.vala
new file mode 100644
index 0000000..ac801af
--- /dev/null
+++ b/tests/control-flow/bug652549.vala
@@ -0,0 +1,6 @@
+void main () {
+ int foo[2] = {1,1};
+ foreach (var bar in foo) {
+ assert (bar == 1);
+ }
+}
diff --git a/vala/valaforeachstatement.vala b/vala/valaforeachstatement.vala
index 2ce466d..a518a2b 100644
--- a/vala/valaforeachstatement.vala
+++ b/vala/valaforeachstatement.vala
@@ -374,7 +374,7 @@ public class Vala.ForeachStatement : Block {
context.analyzer.current_symbol = context.analyzer.current_symbol.parent_symbol;
- collection_variable = new LocalVariable (collection_type, "%s_collection".printf (variable_name));
+ collection_variable = new LocalVariable (collection_type.copy (), "%s_collection".printf (variable_name));
add_local_variable (collection_variable);
collection_variable.active = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]