NetLogo/NetLogo — Issue #12: can't import world containing nested arrays or tables
Author: SethTisue
Created: 2011-11-03 16:00:05+00:00
State: open

(included in docs/issues.html)

add this to TestImportExport.scala:
```scala
@Test def testImportingArrayInsideArray() {
val filename = getUniqueFilename
new java.io.File( filename ).delete()
workspace.initForTesting(5, "globals [ar1] extensions [ array ]" )
testCommand( "set ar1 array:from-list (list array:from-list [5])" )
testCommand( "export-world \"" + filename + "\"" )
testCommand( "ca" )
testCommand( "import-world \"" + filename + "\"" )
testReporter( "array:to-list array:item ar1 0", "[5]")
}
```

result is:
```text
got a nonfatal error Warning: Error importing arrays: Error Importing at Line 176: Expected breed
Action to be Taken: This array will be ignored
There was 1 failure:
1) testImportingArrayInsideArray(org.nlogo.headless.TestImportExport)
org.nlogo.nvm.EngineException: Extension exception: 0 is not a valid index into an array of length 0
```

the original exception is:
```
Expected breed at position 4 in
at org.nlogo.compiler.CompilerExceptionThrowers$.exception(CompilerExceptionThrowers.scala:12)
at org.nlogo.compiler.CompilerExceptionThrowers$.cAssert(CompilerExceptionThrowers.scala:6)
at org.nlogo.compiler.ConstantParser.parseConstantAgentOrAgentSet(ConstantParser.scala:206)
at org.nlogo.compiler.ConstantParser.readConstantPrefix(ConstantParser.scala:99)
at org.nlogo.compiler.ConstantParser.parseConstantList(ConstantParser.scala:127)
at org.nlogo.compiler.ConstantParser.readConstantPrefix(ConstantParser.scala:97)
at org.nlogo.compiler.ConstantParser.getConstantValue(ConstantParser.scala:64)
at org.nlogo.compiler.Compiler$.readFromString(Compiler.scala:79)
at org.nlogo.workspace.Evaluator.readFromString(Evaluator.java:290)
at org.nlogo.workspace.AbstractWorkspace.readFromString(AbstractWorkspace.java:867)
at org.nlogo.workspace.ExtensionManager.readFromString(ExtensionManager.java:527)
at org.nlogo.extensions.array.ArrayExtension.readExtensionObject(ArrayExtension.java:184)
at org.nlogo.workspace.ExtensionManager.readExtensionObject(ExtensionManager.java:560)
at org.nlogo.compiler.ConstantParser.parseConstantLiteral(ConstantParser.scala:138)
at org.nlogo.compiler.ConstantParser.readConstantPrefix(ConstantParser.scala:93)
at org.nlogo.compiler.ConstantParser.getConstantValue(ConstantParser.scala:64)
at org.nlogo.compiler.Compiler$.readFromString(Compiler.scala:79)
at org.nlogo.workspace.Evaluator.readFromString(Evaluator.java:290)
at org.nlogo.workspace.AbstractWorkspace.readFromString(AbstractWorkspace.java:867)
at org.nlogo.workspace.ExtensionManager.readFromString(ExtensionManager.java:527)
at org.nlogo.extensions.array.ArrayExtension.importWorld(ArrayExtension.java:151)
at org.nlogo.workspace.ExtensionManager.importExtensionData(ExtensionManager.java:833)
at org.nlogo.workspace.AbstractWorkspace.importExtensionData(AbstractWorkspace.java:111)
at org.nlogo.agent.Importer.importExtensionData(Importer.java:471)
at org.nlogo.agent.Importer.importWorld(Importer.java:177)
at org.nlogo.agent.World.importWorld(World.java:193)
at org.nlogo.workspace.AbstractWorkspace$4.doImport(AbstractWorkspace.java:650)
at org.nlogo.workspace.AbstractWorkspace.doImport(AbstractWorkspace.java:713)
at org.nlogo.workspace.AbstractWorkspace.importWorld(AbstractWorkspace.java:643)
at org.nlogo.prim.etc._importworld$1.run(_importworld.java:28)
at org.nlogo.headless.HeadlessWorkspace.waitFor(HeadlessWorkspace.java:162)
at org.nlogo.prim.etc._importworld.perform(_importworld.java:23)
at org.nlogo.nvm.Context.stepConcurrent(Context.java:95)
at org.nlogo.nvm.ConcurrentJob.step(ConcurrentJob.java:95)
at org.nlogo.job.JobThread.runPrimaryJobs(JobThread.java:194)
at org.nlogo.job.JobThread.run(JobThread.java:117)
```

exported world has:
```
"EXTENSIONS"

"array"
"{{array: 0: 5}}"
"{{array: 1: {{array: 0}}}}"
```