From 1c35ce68568d0ade1b94d1d3fa3b561f59ceb700 Mon Sep 17 00:00:00 2001 From: Ugric Date: Tue, 28 Mar 2023 21:16:12 +0100 Subject: [PATCH 1/5] fix trig functions --- src/trig.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/trig.go b/src/trig.go index 9c120cf..6c9029e 100644 --- a/src/trig.go +++ b/src/trig.go @@ -181,7 +181,7 @@ var ArArccosec = builtinFunc{"arccosec", func(args ...any) (any, ArErr) { } num := args[0].(number) n, _ := num.Float64() - if n < -1 || n > 1 { + if n > -1 && n < 1 { return nil, ArErr{TYPE: "Runtime Error", message: fmt.Sprintf("arccosec expected number between -1 and 1, got %s", anyToArgon(n, true, true, 3, 0, false, 0)), EXISTS: true, @@ -229,7 +229,7 @@ var ArArcsec = builtinFunc{"arcsec", func(args ...any) (any, ArErr) { } num := args[0].(number) n, _ := num.Float64() - if n < -1 || n > 1 { + if n > -1 && n < 1 { return nil, ArErr{TYPE: "Runtime Error", message: fmt.Sprintf("arcsec expected number between -1 and 1, got %s", anyToArgon(n, true, true, 3, 0, false, 0)), EXISTS: true, From c5c5fef4bccd6859c7914c8ec82f9995a47e1d4f Mon Sep 17 00:00:00 2001 From: Ugric Date: Tue, 28 Mar 2023 21:20:18 +0100 Subject: [PATCH 2/5] fix broken try catch parse --- src/trycatch.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/trycatch.go b/src/trycatch.go index 0866139..4d37bb5 100644 --- a/src/trycatch.go +++ b/src/trycatch.go @@ -28,6 +28,9 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat return TryCatch{}, false, err, i } totalIndex += i + if index+totalIndex >= len(codelines) { + return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i + } catchtrimmed := strings.TrimSpace(codelines[index+totalIndex].code) if !catchCompiled.MatchString(catchtrimmed) { return TryCatch{}, false, ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}, i @@ -36,7 +39,6 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat catchbracketSplit := strings.SplitN(catchtrimmed, ")", 2) errorName := strings.TrimSpace(strings.TrimSpace(catchbracketSplit[0])[1:]) errcode := catchbracketSplit[1] - catchparsed, worked, err, i := translateVal(UNPARSEcode{errcode, code.realcode, code.line, code.path}, index+totalIndex, codelines, 1) if !worked { return TryCatch{}, false, err, i From 2196fc2cf66d516bb0f18655a6fce9420071d078 Mon Sep 17 00:00:00 2001 From: William Bell <62452284+Ugric@users.noreply.github.com> Date: Tue, 28 Mar 2023 21:58:18 +0100 Subject: [PATCH 3/5] Update issue templates --- .github/ISSUE_TEMPLATE/bug_report.md | 38 +++++++++++++++++++++++ .github/ISSUE_TEMPLATE/feature_request.md | 20 ++++++++++++ 2 files changed, 58 insertions(+) create mode 100644 .github/ISSUE_TEMPLATE/bug_report.md create mode 100644 .github/ISSUE_TEMPLATE/feature_request.md diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md new file mode 100644 index 0000000..dd84ea7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -0,0 +1,38 @@ +--- +name: Bug report +about: Create a report to help us improve +title: '' +labels: '' +assignees: '' + +--- + +**Describe the bug** +A clear and concise description of what the bug is. + +**To Reproduce** +Steps to reproduce the behavior: +1. Go to '...' +2. Click on '....' +3. Scroll down to '....' +4. See error + +**Expected behavior** +A clear and concise description of what you expected to happen. + +**Screenshots** +If applicable, add screenshots to help explain your problem. + +**Desktop (please complete the following information):** + - OS: [e.g. iOS] + - Browser [e.g. chrome, safari] + - Version [e.g. 22] + +**Smartphone (please complete the following information):** + - Device: [e.g. iPhone6] + - OS: [e.g. iOS8.1] + - Browser [e.g. stock browser, safari] + - Version [e.g. 22] + +**Additional context** +Add any other context about the problem here. diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md new file mode 100644 index 0000000..bbcbbe7 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -0,0 +1,20 @@ +--- +name: Feature request +about: Suggest an idea for this project +title: '' +labels: '' +assignees: '' + +--- + +**Is your feature request related to a problem? Please describe.** +A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] + +**Describe the solution you'd like** +A clear and concise description of what you want to happen. + +**Describe alternatives you've considered** +A clear and concise description of any alternative solutions or features you've considered. + +**Additional context** +Add any other context or screenshots about the feature request here. From be2ac857ca8041601cd6e91ab1813dc4b186f63b Mon Sep 17 00:00:00 2001 From: Ugric Date: Tue, 28 Mar 2023 22:51:41 +0100 Subject: [PATCH 4/5] add panic and repo config --- src/config.go | 9 +++++++++ src/main.go | 21 +++++++++++++++++++++ src/trycatch.go | 8 +++++--- 3 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 src/config.go diff --git a/src/config.go b/src/config.go new file mode 100644 index 0000000..1aa3275 --- /dev/null +++ b/src/config.go @@ -0,0 +1,9 @@ +package main + +var websiteLang = "https://argon.wbell.dev/" +var docs = "https://argon.wbell.dev/docs/" +var mainrepo = "https://github.com/Open-Argon/argon-v3" +var mainissuesPage = "https://github.com/Open-Argon/argon-v3/issues" +var fork = false +var forkrepo = "" +var forkissuesPage = "" diff --git a/src/main.go b/src/main.go index 2f0a21c..c46e91b 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" ) @@ -17,6 +18,26 @@ func newscope() ArObject { } func main() { + defer func() { + if r := recover(); r != nil { + fmt.Println("There was a fundamental error in argon v3 that caused it to crash.") + fmt.Println() + if fork { + fmt.Println("This is a fork of Open-Argon. Please report this to the fork's maintainer.") + fmt.Println("Fork repo:", forkrepo) + fmt.Println("Fork issue page:", forkissuesPage) + fmt.Println() + } else { + fmt.Println("Please report this to the Open-Argon team.") + fmt.Println("Main repo:", mainrepo) + fmt.Println("Issue page:", mainissuesPage) + fmt.Println() + } + fmt.Println("please include the following information:") + fmt.Println("panic:", r) + os.Exit(1) + } + }() initRandom() garbageCollect() global := makeGlobal() diff --git a/src/trycatch.go b/src/trycatch.go index 4d37bb5..3817ba1 100644 --- a/src/trycatch.go +++ b/src/trycatch.go @@ -28,9 +28,11 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat return TryCatch{}, false, err, i } totalIndex += i - if index+totalIndex >= len(codelines) { - return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i - } + /* + if index+totalIndex >= len(codelines) { + return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i + } + */ catchtrimmed := strings.TrimSpace(codelines[index+totalIndex].code) if !catchCompiled.MatchString(catchtrimmed) { return TryCatch{}, false, ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}, i From d1cd747e86d4c55ba83bb0a3ded61126846e7437 Mon Sep 17 00:00:00 2001 From: Ugric Date: Tue, 28 Mar 2023 23:09:51 +0100 Subject: [PATCH 5/5] fix catch error --- src/trycatch.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/trycatch.go b/src/trycatch.go index 3817ba1..9521950 100644 --- a/src/trycatch.go +++ b/src/trycatch.go @@ -28,11 +28,10 @@ func parseTryCatch(code UNPARSEcode, index int, codelines []UNPARSEcode) (TryCat return TryCatch{}, false, err, i } totalIndex += i - /* - if index+totalIndex >= len(codelines) { - return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i - } - */ + + if index+totalIndex >= len(codelines) { + return TryCatch{}, false, ArErr{"Syntax Error", "expected catch statement", code.line, code.path, code.realcode, true}, i + } catchtrimmed := strings.TrimSpace(codelines[index+totalIndex].code) if !catchCompiled.MatchString(catchtrimmed) { return TryCatch{}, false, ArErr{"Syntax Error", "invalid syntax", code.line, code.path, code.realcode, true}, i