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. diff --git a/merge.bat b/merge.bat new file mode 100644 index 0000000..c41102f --- /dev/null +++ b/merge.bat @@ -0,0 +1,2 @@ +git fetch upstream +git merge upstream/master master \ No newline at end of file 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 9ee9e7e..90054bf 100644 --- a/src/main.go +++ b/src/main.go @@ -1,6 +1,7 @@ package main import ( + "fmt" "os" "syscall/js" ) @@ -19,6 +20,27 @@ func newscope() ArObject { func main() { c := make(chan ArObject) + 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() obj := js.Global().Get("Object").New() obj.Set("eval", js.FuncOf(func(this js.Value, args []js.Value) interface{} { 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, diff --git a/src/trycatch.go b/src/trycatch.go index 0866139..9521950 100644 --- a/src/trycatch.go +++ b/src/trycatch.go @@ -28,6 +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 + } 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 +40,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