Pjoelj

ConceptSPEC bug (minimal example)

Dec 1st, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.47 KB | None | 0 0
  1.  
  2. function get_name()
  3.     return "BUG REPORT"
  4. end
  5.  
  6.  
  7. function get_description()
  8.     return {
  9.         "*messy* is what happens when you use non-number keys. I wouldn't actually expect it to work.",
  10.         "*outOfOrder* is an input which I attempted to fill backwards. It didn't work out.",
  11.         "*outOfOrder2*, *outOfOrder3* and *outOfOrder4* are copies of *outOfOrder*"
  12.     }
  13. end
  14.  
  15.  
  16. function get_board()
  17.     return [[
  18.         ..................
  19.         ..................
  20.         ..................
  21.         ..................
  22.         ....0.1.2.3.4.5...
  23.         ..................
  24.         ..................
  25.     ]]
  26. end
  27.  
  28.  
  29. function get_data()
  30.     outOfOrder = {}
  31.     outOfOrder[4] = 4
  32.     outOfOrder[3] = 3
  33.     outOfOrder[2] = 2
  34.     outOfOrder[1] = 1
  35.     -- This becomes 4, 3, 2, 1 rather than 1, 2, 3, 4
  36.    
  37.     copy1 = {}
  38.     for i=1,#outOfOrder do
  39.       copy1[i] = outOfOrder[i]
  40.     end
  41.     -- This ends up getting properly set (1,2,3,4), as outOfOrder should've been
  42.    
  43.     copy2 = {}
  44.     for k,v in pairs(outOfOrder) do
  45.       copy2[k] = v
  46.     end
  47.     -- But this doesn't (4,3,2,1)
  48.    
  49.     copy3 = {}
  50.     for k,_ in pairs(outOfOrder) do
  51.       copy3[k] = outOfOrder[k]
  52.     end
  53.     -- And neither does this (4,3,2,1)
  54.    
  55.     -- And here's a more extreme example
  56.     nonNumberKeys = {}
  57.     nonNumberKeys["foo"] = 1 -- Why does this work?
  58.     nonNumberKeys["bar"] = 2 -- This should be a COMPILE ERROR, no?
  59.     nonNumberKeys["baz"] = 3
  60.     nonNumberKeys[99] = 4
  61.     nonNumberKeys[98] = 5
  62.     nonNumberKeys[98] = 6 -- Actually manages to overwrite the 5
  63.     nonNumberKeys[3] = 7 -- Doesn't overwrite anything.
  64.     nonNumberKeys[2] = 8 -- Doesn't overwrite anything either.
  65.     -- In the end, this becomes 1,2,3,4,6,7,8
  66.    
  67.     -- Adding packets to the timeline out of order works fine, though
  68.     whatOfTheTimeline = {}
  69.     whatOfTheTimeline[3] = {3}
  70.     whatOfTheTimeline[2] = {2}
  71.     whatOfTheTimeline[1] = {1}
  72.     -- whatOfTheTimeline["cabbage"] = {0} -- COMPILE ERROR, as you'd expect
  73.    
  74.     create_terminal("non-numbers", "0", TYPE_XBUS, DIR_INPUT, {nonNumberKeys})
  75.     create_terminal("outOfOrder", "1", TYPE_XBUS, DIR_INPUT, {outOfOrder})
  76.     create_terminal("outOfOrder2", "2", TYPE_XBUS, DIR_INPUT, {copy1})
  77.     create_terminal("outOfOrder3", "3", TYPE_XBUS, DIR_INPUT, {copy2})
  78.     create_terminal("outOfOrder4", "4", TYPE_XBUS, DIR_INPUT, {copy3})
  79.     create_terminal("timeLineTest", "5", TYPE_XBUS, DIR_INPUT, whatOfTheTimeline)
  80. end
Advertisement
Add Comment
Please, Sign In to add comment