Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

wrong error on load "1abcde" #2036

Closed
rebolbot opened this issue Jul 2, 2013 · 4 comments
Closed

wrong error on load "1abcde" #2036

rebolbot opened this issue Jul 2, 2013 · 4 comments

Comments

@rebolbot
Copy link
Collaborator

rebolbot commented Jul 2, 2013

Submitted by: IngoHohmann

LOADing a number followed by upto 4 characters returns an invalid integer error.
With more than 4 characters invalid decimal is returned

>> load "1abcd"   
** Syntax error: invalid "integer" -- "1abcd"
** Where: to case load
** Near: (line 1) 1abcd

>> load "1abcde"
** Syntax error: invalid "decimal" -- "1abcde"
** Where: to case load
** Near: (line 1) 1abcde

CC - Data [ Version: r3 master Type: Bug Platform: All Category: Error Handling Reproduce: Always Fixed-in:none ]

@rebolbot
Copy link
Collaborator Author

rebolbot commented Jul 3, 2013

Submitted by: BrianH

It's guessing you're trying to write a decimal because of the e, which it interprets as an attempt at scientific notation. It's an error either way, so it's not really a bug.

@rebolbot
Copy link
Collaborator Author

rebolbot commented Jul 4, 2013

Submitted by: IngoHohmann

I find the difference between raised errors unintuitive, and they make it hard to use transcode/next/error

See this difference between "1km" and "1miles"

>> transcode/next/error to binary! "1km"
== [make error! [
        code: 200
        type: 'Syntax
        id: 'invalid
        arg1: "integer"
        arg2: "1km"
        arg3: none
        near: "(line 1) 1km"
        where: [transcode]
    ] #{}]
>> transcode/next/error to binary! "1miles"
== [make error! [
        code: 200
        type: 'Syntax
        id: 'invalid
        arg1: "decimal"
        arg2: "1miles"
        arg3: none
        near: "(line 1) 1miles"
        where: [transcode]
    ] #{}]

Furthermore, the error may hint at a possible place for optimization. The moment, that a character other than "e" is found, it is clear that it is an error, so why check the following characters, wether there might be an "e"?

@rebolbot
Copy link
Collaborator Author

rebolbot commented Jul 8, 2013

Submitted by: BrianH

TRANSCODE needs a lot of work (see #1327, #1857, #1915, #1916, and possibly #537, plus any syntax tickets), so we might want to adjust things. However, I don't think that you are right here. The errors triggered or returned by TRANSCODE are some of its most important features, and we need to make them as useful as possible.

Given that what you are trying to load is not correct, TRANSCODE can only apply some heuristics and guess that you were trying to do. Seeing whether there is an e there is a reasonable clue that you were failing to write a decimal, rather than failing to write an integer. TRANSCODE can't read your mind, it has to go by the evidence at hand to guess your intentions. Nonetheless, tweaking the heuristics (like in #537) might help us improve the errors triggered.

@rebolbot
Copy link
Collaborator Author

Submitted by: Ladislav

"The errors triggered or returned by TRANSCODE are some of its most important features, and we need to make them as useful as possible." - agreed.

However, Ingo is right that after finding out that there was an error it is a bad idea to parse additional characters from the input. Without a mind-reading module TRANSCODE cannot guess what the intent was. (might have been some kind of cut&paste error inserting some garbage)

The most useful information for me would be a part of input found to be wrong by TRANSCODE. What it was meant to be is not useful since there is no way how to correctly determine that.

# for free to join this conversation on GitHub. Already have an account? # to comment
Projects
None yet
Development

No branches or pull requests

1 participant