kin-lang / kin

The Kin Programming Language ( Write computer programs in Kinyarwanda - native language for Rwandans )
https://kinlang.dev
MIT License
209 stars 11 forks source link

Kin Error: Unhandled: undefined #109

Closed MicoDan closed 5 months ago

MicoDan commented 5 months ago

I encountered an error "Unhandled: undefined" while implementing the quick sort algorithm in Kin Lang. Here is the code snippet that produces the error:

reka urutonde_rwi_imibare = [34, 56, 23, 45, 34, 57]

porogaramu_ntoya igabanye(urutonde_rwi_imibare, hasi, hejuru) {
  reka pivot = urutonde_rwi_imibare[hejuru]
  reka i = hasi - 1

  reka j = hasi
  subiramo_niba(j < hejuru) {
    niba(urutonde_rwi_imibare[j] <= pivot) {
      i = i + 1
      reka ububiko_bwagateganyo = urutonde_rwi_imibare[i]
      urutonde_rwi_imibare[i] = urutonde_rwi_imibare[j]
      urutonde_rwi_imibare[j] = ububiko_bwagateganyo
    }
    j = j + 1
  }
  reka ububiko_bwagateganyo = urutonde_rwi_imibare[i + 1]
  urutonde_rwi_imibare[i + 1] = urutonde_rwi_imibare[hejuru]
  urutonde_rwi_imibare[hejuru] = ububiko_bwagateganyo
  garura i + 1
}

porogaramu_ntoya quick_sort(urutonde_rwi_imibare, hasi, hejuru) {
  niba(hasi < hejuru) {
    reka pivot_index = igabanye(urutonde_rwi_imibare, hasi, hejuru)
    quick_sort(urutonde_rwi_imibare, hasi, pivot_index - 1)
    quick_sort(urutonde_rwi_imibare, pivot_index + 1, hejuru)
  }
}

reka hasi = 0
reka hejuru = KIN_URUTONDE.ingano(urutonde_rwi_imibare) - 1
quick_sort(urutonde_rwi_imibare, hasi, hejuru)

reka i = 0
subiramo_niba(i < KIN_URUTONDE.ingano(urutonde_rwi_imibare)) {
  tangaza_amakuru(urutonde_rwi_imibare[i])
  i = i + 1
}

Error Message: The error occurs on line 2: "Kin Error: Unhandled: undefined".

Context: I am trying to implement merge sort in Kin Lang. The error seems to be related to the array slicing or loop conditions. Any guidance or fixes would be appreciated.

pacifiquem commented 5 months ago

There're issues in the way Kin handles errors.... lemme check it 👍

pacifiquem commented 5 months ago

This is the error that you've.

Screenshot 2024-05-16 104123

pacifiquem commented 5 months ago

There have been an issue with how Kin handles errors as communicated early, this is fixed for now and those fixes will appear in @kin-lang/kin - v0.3.0 which will be released later this week

pacifiquem commented 5 months ago

This is the error that you've.

Screenshot 2024-05-16 104123

In Kin we don't use garura we use tanga.

MicoDan commented 5 months ago

Okay, got it, thank you very much.