seanbaxter / circle

The compiler is available for download. Get it!
http://www.circle-lang.org/
2.42k stars 74 forks source link

Code that compiles fine fail with '#feature on safety' #203

Open mingodad opened 5 months ago

mingodad commented 5 months ago

While testing the latest build-204 and the #feature on safety on an amalgamation of https://github.com/mingodad/squilu I can get it to build/execute fine when #feature on safety is not defined otherwise I'm getting some errors that doesn't seem related to the safety checks (see attached all code needed to reproduce the problem):

mk-squilu-circle.sh
error: am-squilu.cpp:1124:15
        resize(old_size + count); 
              ^
no viable candidates in call to resize
  object is lvalue SQCharBuf
  argument 0 is prvalue unsigned long long
  candidate: am-squilu.cpp:1037:8
    void resize(SQSizeType newsize, const T& fill = T()) 
         ^
    error: am-squilu.cpp:1124:15
            resize(old_size + count); 
                  ^
    could not bind implicit object parameter sqvector<char>& to lvalue SQCharBuf

error: am-squilu.cpp:1351:10
    _type=OT_NULL; 
         ^
left operand prvalue const tagSQObjectType& in assignment must be lvalue

error: am-squilu.cpp:1357:7
      _constructWith(o); 
      ^
use -> to access members through lvalue const SQObjectPtr&

error: am-squilu.cpp:1357:7
      _constructWith(o); 
      ^
use -> to access members through lvalue const SQObjectPtr&

error: am-squilu.cpp:1361:7
      _constructWith(o); 
      ^
use -> to access members through lvalue const tagSQObject&

error: am-squilu.cpp:1361:7
      _constructWith(o); 
      ^
use -> to access members through lvalue const tagSQObject&

error: am-squilu.cpp:1364:3
  _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
  ^
left operand prvalue const tagSQObjectType& in assignment must be lvalue

error: am-squilu.cpp:1364:3
  _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
  ^
cannot narrow int to bool

error: am-squilu.cpp:1364:3
  _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
  ^
left operand prvalue const tagSQObjectType& in assignment must be lvalue

error: am-squilu.cpp:1364:3
  _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
  ^
no viable candidates in call to Release
  object is lvalue SQRefCounted
  candidate: am-squilu.cpp:1220:3
    ABSTRACT_METHOD(virtual void Release(), {}) 
    ^
    error: am-squilu.cpp:1364:3
      _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
      ^
    could not bind implicit object parameter SQRefCounted& to lvalue SQRefCounted

error: am-squilu.cpp:1364:3
  _REF_TYPE_DECL(OT_TABLE,SQTable,Table) 
  ^
cannot convert lvalue SQObjectPtr to SQObjectPtr&
SQObjectPtr declared at am-squilu.cpp:1346:1

error: translation aborted; too many errors

mk-squilu-circle.sh:

optim=-O2
#CXX=g++
#CXX="clang-18-env clang++"
CXX="circle -DCIRCLE_SAFETY_ON"
#CXX=circle

$CXX $optim  -fno-rtti -Wall \
    -DNDEBUG -DONLY_ASCII -DNO_ABSTRACT_METHOD -DCUSTOM_DELETE_OPERATOR -DSQ_USE_MKSTEMP  -DSQ_ENABLE_INCLUDES -DSQ_SUBLATIN -DNEED_SUBLATIN_C -DSQUSEDOUBLE \
    -D__SQAMALGAMATION__ -D_SQ64 -DMAKE_SQ_CMD am-squilu.cpp -o am-squilu-circle
mingodad commented 5 months ago

Here is all code needed to reproduce the issue. am-squilu.cpp.zip