Skip to content

Add colors and primitive functions to the create_wrappers errors.

Quinten Cabo requested to merge prf_and_color_in_create_wrappers_errors into develop

Now primitive functions calls will be suggested if you try to call a function that does not exist that starts with an underscore. We use the list of primitive functions defined in prf_info.mac. Closes #2566 (closed).

To find the prf you most likely meant we look through the prf three times, each time with a less restrictive filter.

  1. For the first time we only consider prf where the function call by the programmer is a prefix of the prf.
  2. If that leads to nothing we consider all the prf where the function call by the programmer is a prefix of the prf if you would make one edit to the function call by the programmer
  3. If that also leads to nothing we consider all prf with a max edit distance of 4.

If that also leads to nothing or the function call did not start with a _ we use the already existing strategy and look through the defined functions.

I also took this opportunity to add some color to the create_wrappers error which actually makes it a lot more clear because you immediately can find the suggested name if you have seen this error message before.

Example error messages

./wrap.sac:3:6-10: error:
  2. int main() {
  3.  a = _addd(3,3);
          ~~~~~
  4.  return a;
  5. }
  
  The '_addd' function is not defined anywhere.
  Suggestion: A primitive function named _add_SxS_ does exist. Did you mean to call that instead?
./wrap.sac:3:6-9: error:
  2. int main() {
  3.  a = _div(3,3);
          ~~~~
  4.  return a;
  5. }
  
  The '_div' function is not defined anywhere.
  Suggestion: A primitive function named _div_SxS_ does exist. Did you mean to call that instead?
./wrap.sac:3:6-10: error:
  2. int main() {
  3.  a = _hide(3,3);
          ~~~~~
  4.  return a;
  5. }
  
  The '_hide' function is not defined anywhere.
  Suggestion: A primitive function named _hideDim_SxA_ does exist. Did you mean to call that instead?
./wrap.sac:3:6-11: error:
  2. int main() {
  3.  a = _hideV(3,3);
          ~~~~~~
  4.  return a;
  5. }
  
  The '_hideV' function is not defined anywhere.
  Suggestion: A primitive function named _hideValue_SxA_ does exist. Did you mean to call that instead?

Merge request reports