Wiki

Ticket #131 (closed defect: fixed)

Opened 15 years ago

Last modified 15 years ago

Fractional literals outside Decimal/float type range give assert error

Reported by: hopscc Owned by: Chuck
Priority: minor Milestone:
Component: Cobra Compiler Version: 0.8.0
Keywords: Cc:

Description

If specify a Decimal literal outside of the range for its type or do the same for float32 get a really horrible assert error and stack trace rather than an error diagnostic

# literal > Max_Decimal
b  = 80_228_162_514_264_337_593_543_950_335.1

gives

Unhandled Exception: Cobra.Lang_ert_635e27de755dde73ac9b558e38a46201.AssertException:
sourceSite = C:\home\hops\src\cobra\wkspace\Source\CobraTokenizer.cobra:505 in CobraTokenizer.onFRACTIONAL_LIT for object CobraTokenizer(_sourceLineIndex=56, _lineNum=9, _colNum=57, _charNum=322, _indentCount=2, _substLBracketCount=0, _inSubstStringSingle=false, _inSubstStringDouble=false, _inDocString=false_inCommentBlock=0)
info       = 'TODO: FRACTIONAL_LIT Overflow'
this       = CobraTokenizer(_sourceLineIndex=56, _lineNum=9, _colNum=57, _charNum=322, _indentCount=2, _substLBracketCount=0, _inSubstStringSingle=false, _inSubstStringDouble=false, _inDocString=false_inCommentBlock=0)

   at Tokenizer._tokenPostProcess(MethodInfo meth, IToken tok) in c:\home\hops\src\cobra\wkspace\Source\Tokenizer.cobra:line 728
   at Tokenizer.get__nextToken() in c:\home\hops\src\cobra\wkspace\Source\Tokenizer.cobra:line 649
   at CobraTokenizer.get__nextToken() in c:\home\hops\src\cobra\wkspace\Source\CobraTokenizer.cobra:line 273
   at Tokenizer.get__nextToken() in c:\home\hops\src\cobra\wkspace\Source\Tokenizer.cobra:line 662
   at CobraTokenizer.get__nextToken() in c:\home\hops\src\cobra\wkspace\Source\CobraTokenizer.cobra:line 273
   at Tokenizer.get_NextToken() in c:\home\hops\src\cobra\wkspace\Source\Tokenizer.cobra:line 445
   at Tokenizer.AllTokens() in c:\home\hops\src\cobra\wkspace\Source\Tokenizer.cobra:line 461
   at Parser._preParseSource(String fileName, String source) in c:\home\hops\src\cobra\wkspace\Source\CobraParser.cobra:line 225
   at Parser.ParseSource(String fileName, String source) in c:\home\hops\src\cobra\wkspace\Source\CobraParser.cobra:line 191
   at Parser.ParseFileNamed(String fileName) in c:\home\hops\src\cobra\wkspace\Source\CobraParser.cobra:line 179
   at Compiler.ParseFilesNamed(IList`1 filenames) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 439
   at Compiler._compileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 297
   at Compiler.CompileFilesNamed(IList`1 paths, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\home\hops\src\cobra\wkspace\Source\Compiler.cobra:line 264
   at CommandLine.DoCompile(List`1 paths, Boolean willPrintSuccessMsg, Boolean writeTestInvocation, Boolean stopAfterBindInt) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 570
   at CommandLine.DoRun(List`1 paths) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 646
   at CommandLine.Run(List`1 args) in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 543
   at CommandLine.Run() in c:\home\hops\src\cobra\wkspace\Source\CommandLine.cobra:line 485
   at CobraMain.Main() in c:\home\hops\src\cobra\wkspace\Source\cobra.cobra:line 13
(null)

The 'TODO' clauses in caught overflow exceptions around decimal,float.parse need implementing in CobraTokeniser.cobra

Attachments

numeric-ovfl.patch Download (4.6 KB) - added by hopscc 15 years ago.

Change History

Changed 15 years ago by Chuck

If they use an installed cobra.exe and don't pass -reveal-internal-exceptions they should just get something along the lines of a one-liner:

error: COBRA INTERNAL ERROR / InvalidCastException / Specified cast is not valid.

which is bad, but not horribly long.

Changed 15 years ago by Chuck

  • priority changed from major to minor

Btw changing this to minor unless there is some reason to believe that this comes up often.

Changed 15 years ago by hopscc

I get the above (first post) stack dumpage when run against a copy of the latest src tree...
How often it occurs depends on how much it will be used for numeric processing on cases that hit the type range boundaries...
I've tweaked some of them already so there'll be a patch surfacing sometime soonish

Changed 15 years ago by hopscc

  • owner set to hopscc
  • status changed from new to assigned

Changed 15 years ago by hopscc

Changed 15 years ago by hopscc

  • owner changed from hopscc to Chuck

patch changing asserts to error diagnostic, tests and relnote line.
Will need more tests when support exponential notation for literals

Changed 15 years ago by Chuck

  • status changed from assigned to closed
  • resolution set to fixed

Applied in changeset:1902

Made some further enhancements. For example, the range overflows are done with .recordError instead of .throwError so more errors can be reported. Fixed mixed case in error messages. etc.

Note: See TracTickets for help on using tickets.