Gidsss / UwUIDE

A compiler made to be cute uwu >~<
6 stars 0 forks source link

Refactor/array dimension type checking #275

Closed am-cid closed 5 months ago

am-cid commented 5 months ago

array overhaul

  1. Arrays can have a dimension defined at declaration
    • if none is defined, its defaulted to 1
    • if less than 1 is defined, it will be floored to 1, no error
  2. arrays must be homogeneous
    • chan[3] elements must all be chan[2]; chan[100] elements must all be chan[99]; etc
    • all arrays can accept empty arrays though
  3. append() and prepend() expect the unit type of the array type
    • eg: chan[2].append() expects chan[1]; chan[100].append() expects chan[99]; etc
  4. extend() and prextend() expect the array type
    • eg: chan[2].append() expects chan[2]; chan[100].append() expects chan[100]; etc

etc


test logs

image

Declaration Type Mismatch: expected 'chan[11]' but got 'chan[10]'
        ____________________________
             |    Expected type defined here
        8    |         d-chan[11] = a~
             |           ^^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan[10]'
        8..n | |    d-chan[11] = a
             | |                 ^
             | |_________________|
        ____________________________

Declaration Type Mismatch: expected 'chan[10]' but got 'chan[9]'
        _______________________________
             |    Expected type defined here
        9    |         e-chan[10] = a{0}~
             |           ^^^^^^^^
             | __________|
             | |  Tried to assign a value that evaluates to type: 'chan[9]'
        9..n | |    e-chan[10] = a{0}
             | |                 ^^^^
             | |_________________|
        _______________________________

Declaration Type Mismatch: expected 'chan[10]' but got 'chan[8]'
        ____________________________________
              |    Expected type defined here
        10    |         f-chan[10] = a{0}{0}~
              |           ^^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[8]'
        10..n | |    f-chan[10] = a{0}{0}
              | |                 ^^^^^^^
              | |_________________|
        ____________________________________

Declaration Type Mismatch: expected 'chan[10]' but got 'chan[7]'
        _______________________________________
              |    Expected type defined here
        11    |         g-chan[10] = a{0}{0}{0}~
              |           ^^^^^^^^
              | __________|
              | |  Tried to assign a value that evaluates to type: 'chan[7]'
        11..n | |    g-chan[10] = a{0}{0}{0}
              | |                 ^^^^^^^^^^
              | |_________________|
        _______________________________________

image image image image

sample text file
-----------------------------------------------------------
 1 |
 2 |     fwunc mainuwu-san() [[
 3 |         a-chan[10] = {{{{{{{{{{10}}}}}}}}}}~
 4 |         a{0}{0}{0}{0}{0}{0}{0}{0}.append(sum(a))~
 5 |         i-chan = a{0}{0}{0}{0}{0}{0}{0}{0}{0}{0} + 10~
 6 |     ]]
 7 |     fwunc sum-chan(a-chan[10]) [[
 8 |         wetuwn(a{0}{0}{0}{0}{0}{0}{0}{0}{0}{0} + 10)~
 9 |     ]]
10 |
-----------------------------------------------------------
end of file

Call arg type mismatch:
        ______________________________________________________
          |
          |     'chan[2].append()' called here
        4 |         a{0}{0}{0}{0}{0}{0}{0}{0}.append(sum(a))~
          |                                   ^^^^^^
          |
          |     'chan[2].append()' class method expects 1 argument
          |     EXPECTED     ACTUAL     ARG
          |     ✗ chan[1]    chan       sum(a)
        ______________________________________________________