Macaulay2 / M2

The primary source code repository for Macaulay2, a system for computing in commutative algebra, algebraic geometry and related fields.
https://macaulay2.com
347 stars 231 forks source link

value of string terminating in semicolon #3412

Open mahrud opened 3 months ago

mahrud commented 3 months ago

This somewhat surprised me. Shouldn't the value of a string terminating in ";" be null?

i1 : value "new HashTable from {}"

o1 = HashTable{}

o1 : HashTable

i2 : value "new HashTable from {};" -- I expected null, got hash table!

o2 = HashTable{}

o2 : HashTable

i3 : value "(new HashTable from {})"

o3 = HashTable{}

o3 : HashTable

i4 : value "(new HashTable from {};)" -- I expected null, got null

i5 : 

Edit: here is a specific problem that this causes:

i5 : << last capture generateAssertions "12;"

i1 : assert( (12;) === 12 );
currentString:1:1:(3):[7]: error: assertion failed
pzinn commented 2 months ago

it looks like it's intentional (cf the argument returnLastvalue of readeval). but I don't understand why, superficially it seems like a bug.

mahrud commented 2 months ago

Could you point to a line? I'm not sure where in readeval you're referring to.