Bug 15863 - vbnc rejects StreamReader.EndOfStream in loop condition
Summary: vbnc rejects StreamReader.EndOfStream in loop condition
Alias: None
Product: Compilers
Classification: Mono
Component: VisualBasic ()
Version: 3.2.x
Hardware: PC Linux
: --- normal
Target Milestone: ---
Assignee: Rolf Bjarne Kvinge [MSFT]
Depends on:
Reported: 2013-10-31 17:52 UTC by Robert Dodier
Modified: 2013-10-31 21:49 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Robert Dodier 2013-10-31 17:52:51 UTC
I am working with vbnc as built from current Git sources. mono --version reports Mono Runtime Engine version 3.2.5 (master/7516586 Tue Oct 29 22:09:55 EDT 2013), vbnc --version reports Visual Basic.Net Compiler version (Mono 3.0 - master/4dcc70f). Host is RHEL 6.

vbnc rejects StreamReader.EndOfStream in loop condition, but accepts an equivalent local variable.

vbnc accepts this program:

Imports System
Imports System.IO
Public Module modmain
  Dim f as Object
  Dim eof as Boolean
  Sub Main ()
    f = File.OpenText ("foo.in")
    eof = f.EndOfStream
    Do While Not eof
      Console.WriteLine (f.Readline ())
      eof = f.EndOfStream
  End Sub
End Module

vbnc rejects this program:

Imports System
Imports System.IO
Public Module modmain
  Dim f as Object
  Sub Main ()
    f = File.OpenText ("foo.in")
    Do While Not f.EndOfStream
      Console.WriteLine (f.Readline ())
  End Sub
End Module

with this message:

$ vbnc tmp1.vb
Visual Basic.Net Compiler version (Mono 3.0 - master/4dcc70f)
Copyright (C) 2004-2010 Rolf Bjarne Kvinge. All rights reserved.

Missed option: Object_Boolean
/home/ipadmin/tmp/tmp1.vb (5,11)
vbnc : Command line : error VBNC99999: Unexpected error: There has been an internal error in the compiler: 
  at vbnc.Helper.Stop (System.String Message) [0x00017] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/General/Helper.vb:2251 
  at vbnc.Emitter.EmitConversion (Mono.Cecil.TypeReference FromType, Mono.Cecil.TypeReference ToType, vbnc.EmitInfo Info) [0x011af] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Emit/Emitter.vb:818 
  at vbnc.DoStatement.GenerateCode (vbnc.EmitInfo Info) [0x00096] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Statements/DoStatement.vb:93 
  at vbnc.CodeBlock.GenerateCode (vbnc.EmitInfo Info) [0x00149] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Code/CodeBlock.vb:520 
  at vbnc.CodeBlock.GenerateCode (IMethod Method) [0x00060] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Code/CodeBlock.vb:450 
  at vbnc.MethodBaseDeclaration.GenerateCode (vbnc.EmitInfo Info) [0x000b9] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/General/MethodBaseDeclaration.vb:353 
  at vbnc.MethodDeclaration.GenerateCode (vbnc.EmitInfo Info) [0x00006] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Members/MethodDeclaration.vb:74 
  at vbnc.SubDeclaration.GenerateCode (vbnc.EmitInfo Info) [0x00045] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/Members/SubDeclaration.vb:98 
  at vbnc.Helper.GenerateCodeCollection (IEnumerable Collection, vbnc.EmitInfo Info) [0x00036] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/General/Helper.vb:2100 
  at vbnc.BaseObjects`1[vbnc.IMember].GenerateCode (vbnc.EmitInfo Info) [0x00000] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/General/BaseObjects`1.vb:75 
  at vbnc.AssemblyDeclaration.Emit (vbnc.TypeDeclaration Type) [0x00006] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb:129 
  at vbnc.AssemblyDeclaration.Emit () [0x0005e] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/TypeDeclarations/AssemblyDeclaration.vb:633 
  at vbnc.Compiler.Compile () [0x005b2] in /home/ipadmin/mono-git/mono-basic/vbnc/vbnc/source/General/Compiler.vb:543 
Compilation took 00:00:01.1881970
Comment 1 Rolf Bjarne Kvinge [MSFT] 2013-10-31 18:05:24 UTC
What vbnc fails on is the implicitly typed variable. If you declare the variable correctly, vbnc compiles the test code:

  Dim f as StreamReader
Comment 2 Robert Dodier 2013-10-31 18:10:31 UTC
Incidentally, vbnc accepts the same condition (Not f.EndOfStream) in an If
Comment 3 Robert Dodier 2013-10-31 18:48:28 UTC
I've verified that Dim f as StreamReader makes the problem go away.
Comment 4 Rolf Bjarne Kvinge [MSFT] 2013-10-31 21:49:58 UTC

mono-basic/master: 292b6c6b86d0ec59f552e8d0a4149354d7921f20