Classification of programming errors
My context for this question is teaching an introduction to programming. Several introductory textbooks identify three broad types of programming error:
- Syntax error (e.g. missing bracket - the code could not be parsed correctly by the BNF)
- Logical error (for example the common 'off by one' error, or an erroneous algorithm design)
- Runtime error (e.g. a division by zero, null reference, or other exception)
I don't find this framework very satisfactory. There are lots of errors I encounter that don't fit readily into this. For example;
In a statically typed language, lots of errors show up at compile time which aren't syntax errors. For example mis-spelling a method name, or use a variable before it is declared, you get an immediate compile error, even though the code may be syntactically correct. Or type errors. One might call these 'other compile time errors', except that...
In a dynamically typed language (Python being the most common language taught in schools), the same type of errors don't show up until run-time, and again it will throw a specific exception type.
My question really is: is there a good generic name that covers errors in the coding rather than in the logical design i.e. the wrong bit of code could never run correctly with any data - but are not syntax errors, bearing in mind that these errors might show up at compile time or run time depending on whether the language is statically or dynamically typed. Or can one only legitimately refer to the (many) specific types of error that might occur?
I suppose one possibility might be 'semantic errors' - but I don't particularly like it.
do you know?
how many words do you know
See also questions close to this topic
-
To Discord.js master
i got an error. PLZ HELP ME!! I tried the slash command bot. And i have been getting this error. I have tried hard to solve this error. I gave the bot full permission. So, I don't know what to do, so I ask here.
Error content: https://pastebin.com/G0CH6QBK
throw new DiscordAPIError(data, res.status, request); ^ DiscordAPIError: 405: Method Not Allowed at RequestHandler.execute (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/rest/RequestHandler.js:350:13) at processTicksAndRejections (node:internal/process/task_queues:96:5) at async RequestHandler.push (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/rest/RequestHandler.js:51:14) at async ApplicationCommandPermissionsManager.set (/data/data/com.termux/files/home/CM/node_modules/discord.js/src/managers/ApplicationCommandPermissionsManager.js:186:18) at async /data/data/com.termux/files/home/CM/Handlers/Commands.js:60:5 { method: 'put', path: '/applications/971797595313827931/guilds/951450095658872853/commands/permissions', code: 0, httpStatus: 405, requestData: { json: [ { id: '972066482475393044', permissions: [ { id: '951450095658872853', permission: true, type: 1 }, { id: '951469564242321419', permission: true, type: 1 }, { id: '951497606733918221', permission: true, type: 1 }, { id: '951504382413926450', permission: true, type: 1 }, { id: '952860149054312499', permission: true, type: 1 }, { id: '959619628022259735', permission: true, type: 1 }, { id: '961465754526576652', permission: true, type: 1 }, { id: '971431284519870555', permission: true, type: 1 }, { id: '971431411804409917', permission: true, type: 1 }, { id: '971432006678376539', permission: true, type: 1 }, { id: '971432790254030868', permission: true, type: 1 }, { id: '971435796450140241', permission: true, type: 1 }, { id: '971443167545163886', permission: true, type: 1 }, { id: '971444177873285130', permission: true, type: 1 }, { id: '971516546834890814', permission: true, type: 1 }, { id: '971690107688083522', permission: true, type: 1 }, { id: '971952762319421470', permission: true, type: 1 }, { id: '971953522901909524', permission: true, type: 1 }, { id: '972066442621120556', permission: true, type: 1 } ] } ], files: [] } }```
-
count function in python list
Hello comrades, I want to take a character from the input and convert it to a list, and then show the number of repetitions of each index to the user, but it gives an error.
my code:
list = list(input("plase enter keyword")) for item in list: print(f"value({item})"+list.count(item))
my error
TypeError Traceback (most recent call last) c:\Users\emanull\Desktop\test py\main.py in <cell line: 3>() 2 list = list(input("plase enter keyword")) 4 for item in list: ----> 5 print(f"value({item})"+list.count(item)) TypeError: can only concatenate str (not "int") to str
-
binutils error in configure & make some tool
I'm trying to install binutils 2.26 on ubuntu 1804, but I'm getting an error at compile time.
Any help here would be greatly appreciated. Thanks.
- I am trying to compile using the gcc 5.5.0.
me:~/binutils-2.26/binutils$ gcc -o test nm.c In file included from nm.c:21:0: sysdep.h:23:25: fatal error: alloca-conf.h: No such file or directory compilation terminated.
me:~/binutils-2.26/binutils$ gcc -o test readelf.c In file included from readelf.c:43:0: sysdep.h:23:25: fatal error: alloca-conf.h: No such file or directory compilation terminated.
me:~/binutils-2.26/binutils$ gcc -o test debug.c In file included from debug.c:29:0: sysdep.h:23:25: fatal error: alloca-conf.h: No such file or directory compilation terminated.
What dependency am I missing? i want build and compile specific one(nm, size, realelf... etc) without making others..
-
Java a Beginners guide Try this 4-1 gives java.lang.NoSuchMethodError
I am trying an exercise from Java a beginners guide and it gives me the following error:
HelpClassDemo Exception in thread "main" java.lang.NoSuchMethodError: 'void Help.showMenu()' at HelpClassDemo.main(HelpClassDemo.java:72)
I have googled the error and tried to retype it to see if it was an uppercase or lowercase letter issue but it doesn't work. Then I pasted the solution from the book into the program and even that doesn't work. What is wrong in the code?
/* Convert help system in a Help class */ class Help { void helpOn (int what) { switch(what) { case '1': System.out.println("The if:\n"); System.out.println("if(condition) statement;"); System.out.println("else statement;"); break; case '2': System.out.println("The traditional switch:\n"); System.out.println("switch (expression) {"); System.out.println(" case constant:"); System.out.println(" statement sequence"); System.out.println(" break;"); System.out.println(" //..."); System.out.println("}"); break; case '3': System.out.println("The for:\n"); System.out.print("for(init; condition; iteration)"); System.out.println(" statement;"); break; case '4': System.out.println("The while:\n"); System.out.println("while(condition) statement;"); break; case '5': System.out.println("The do-while:\n"); System.out.println("do {"); System.out.println(" statement;"); System.out.println("} while (condition) ;"); break; case '6': System.out.println("The break: \n"); System.out.println("break; or break label;"); break; case '7': System.out.println("The continue:\n"); System.out.println("continue; or continoue label;"); break; } System.out.println(); } void showMenu() { System.out.println("Help on: "); System.out.println(" 1. if "); System.out.println(" 2. switch "); System.out.println(" 3.for"); System.out.println(" 4. while"); System.out.println(" 5. do-while"); System.out.println(" 6. break"); System.out.println(" 7. continue\n"); System.out.println("Choose one: (q to quit): "); } boolean isValid(int choice) { if(choice < '1' | choice > '7' & choice != 'q') return false; else return true; } } class HelpClassDemo { public static void main(String[] args) throws java.io.IOException { char choice, ignore; Help hlpobj = new Help() ; for(;;) { do{ hlpobj.showMenu(); choice = (char) System.in.read(); do{ ignore = (char) System.in.read(); } while(ignore != '\n'); } while( !hlpobj.isValid(choice)); if(choice == 'q') break; System.out.println("\n"); hlpobj.helpOn(choice); } } }
-
Trying to run a cpp program but I get the following error: [process exited with code 3221226356 (0xc0000374)]
I am currently trying to execute the following cpp program on Windows:
#include <cstdlib> #include <iostream> #include "math.h" #include <fstream> using std:: cin; using std:: cout; using std:: endl; using std::ofstream; int main() { //numerical method parameters const int Nx = 500; // nodes count in x-space const int Ny = 500; // nodes count in y-space double hx, hy, tau; hx = 1; // x variable step hy = 1; // y step tau = (hx > hy) ? hy :hx; // time step = min(hx,hy) const int Nt = 1000; // grid double *x = new double[2]; double *y = new double[2]; x[0] = 0.0; y[0] = 0.0; for (int i = 0; i < Nx; i++) { x[i + 1] = x[i] + hx; } for (int j=0; j < Ny; j++) { y[j + 1] = y[j] + hy; } double **Up = new double*[Nx]; // storing values from the previous step U(n+1/2) double **Up1 = new double*[Nx]; // U(n) double **Heat_Coeff = new double*[Nx]; // thermal conductivity (lambda) double A, C, B; // coeff-s of the tridiagonal matrix double F; // F - right side (system of linear equations) double **alpha = new double *[Nx]; // numerical method parameters for "grid function" computation double **betta = new double *[Nx]; for(int i=0; i<Nx; i++) { alpha[i] = new double[Ny]; betta[i] = new double[Ny]; Up[i] = new double[Ny]; Up1[i] = new double[Ny]; Heat_Coeff[i] = new double[1]; } //================================== for(int i=0; i<Nx; i++) { for(int j=0; j<Ny; j++) { Up1[i][j]=300; // init. cond Heat_Coeff[i][j] = 1; alpha[i][j] = 0.0; //Up[i][j] = Up1[i][j]; // copy for the numerical method } } //Upper and lower boundary conditions for (int j = 0; j < Ny; j++) { Up1[0][j] = Up1[j][1]; Up1[Nx-1][j] = Up1[Nx-j-1][Ny-2]; //Up[0][j] = Up1[0][j]; //Up[Nx-1][j] = Up1[Nx-1][j]; betta[0][j] = Up1[0][j]; betta[Nx-1][j] = Up1[Nx-1][j]; } //left and right boundary conditions for (int i = 0; i < Nx; i++) { Up1[i][0] = 50; Up1[i][Ny-1]= 100; //Up[i][0] = Up1[i][0]; //Up[i][Ny-1] = Up1[i][Ny-1]; betta[i][0] = Up1[i][0]; betta[i][Ny-1] = Up1[i][Ny-1]; } for(int time=0; time<Nt; time++) // time loop { cout << "time: " << time << endl << endl; for(int i=0; i< Nx; i++) { for(int j=0; j<Ny; j++) { Up[i][j] = Up1[i][j]; } } for(int j=1; j< Ny-1; j++) // y-loop { for(int i=1; i< Nx-1; i++) { A = - (Heat_Coeff[i-1][j] + Heat_Coeff[i][j]) / (4*hx*hx); B = - (Heat_Coeff[i+1][j] + Heat_Coeff[i][j]) / (4*hx*hx); C = 1/tau - A - B; F = Up[i][j]/tau + ((Heat_Coeff[i][j+1] + Heat_Coeff[i][j]) *(Up[i][j+1]-Up[i][j])-(Heat_Coeff[i][j-1]+Heat_Coeff[i][j])*(Up[i][j]-Up[i][j-1]))/(4*hy*hy); alpha[i][j] = -B / (C+A*alpha[i-1][j]); betta[i][j] = (F - A*betta[i-1][j])/(C + A*alpha[i-1][j]); //cout << "Received beta: " << betta[i][j] << endl << endl; //getch(); } for(int i=Nx-1; i>1; i--) { Up1[i-1][j]=alpha[i-1][j]*Up1[i][j]+betta[i-1][j]; // find Up //Up[i][j] = Up1[i][j]; } } for (int i = 0; i < Nx; i++) { for (int j = 0; j < Ny; j++) { Up[i][j] = Up1[i][j]; // remember array } } for(int i=1; i<Nx-1; i++) // x-loop { for(int j=1; j< Ny-1; j++) { A = - (Heat_Coeff[i][j-1] + Heat_Coeff[i][j]) / (4*hy*hy); B = - (Heat_Coeff[i][j+1] + Heat_Coeff[i][j]) / (4*hy*hy); C = 1/tau - A - B; F = Up[i][j]/tau + ((Heat_Coeff[i+1][j] + Heat_Coeff[i][j])*(Up[i+1][j]-Up[i][j])-(Heat_Coeff[i-1][j]+Heat_Coeff[i][j])*(Up[i][j]-Up[i-1][j]))/(4*hx*hx); alpha[i][j] = -B / (C+A*alpha[i][j-1]); betta[i][j] = (F - A*betta[i][j-1])/(C + A*alpha[i][j-1]); } for(int j=Ny-1; j>1; j--) { Up1[i][j-1]=alpha[i][j-1]*Up1[i][j]+betta[i][j-1]; // find Up1 //Up[i][j] = Up1[i][j]; } } } ofstream outt; //outt.precision(3); outt.open("heat.txt"); for (int i = 0; i < Nx; i++) { for (int j = 0; j < Ny; j++) { outt << Up1[i][j] << " "; } outt << ";" << endl; } outt.close(); //system ("Pause"); return 0; }
However every time I launch the a.exe output I get the following error message:
[process exited with code 3221226356 (0xc0000374)]
The fun fact is that whenever I execute this program on macOS, I don't get any error at all, I really don't know what goes wrong here on windows.
Thank you for your help
-
python won't recognize Pandas
I have python 3.10.4 installed and running perfectly fine, but was given a bigger assignment that seems best suited for pandas. I installed PyCharm (2022.1 Community edition, v11.0.14.1) and that seems to work fine.
I did all the steps to install pandas (ver 1.4.2) and it seems to be in place but no matter what I do as soon as I import it in to my program
import pandas as pd
I get the error:
no module named pandas
while in PyCharm, I do have the pandas package in place for the current project, but nothing seems to be working