cimplec / sim-c

A dynamically typed high-level front end for C

Home Page:https://cimplec.github.io/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[FEATURE REPORT] Improvement of arrays: Differentiate array from variables to avoid bugs and check out for ranges when indexing

Math-O5 opened this issue · comments

Describe the feature
This would be extension of #346, #354 and #344. Arrays are treat as variables and therefore, can be freely used as one.

To Reproduce
We are not differentiating variables from array, so the code where we sum two variables, as example, can be in fact two arrays!

Sim-C:

   var b[10]
   b[0] = 1
   // All line following should throw an error, but it does not!
   c = b[b] 
   d = b * 2 + b 
   e[10]
   e[b + b] = 10
   f = e[b + b] 

Expected behavior
We should add another metadata type for array and one filed more in the Symbol Table, then add a case on expression function in simc_parser.py to know if we are indexing the array 'b[x]' or using it raw without indexing!

Desktop (please complete the following information):

  • OS: Fedora 30.0.x

Additional context
Start this issue only if you look at CONTRIBUTING.md file